diff --git a/VPRJ.m b/VPRJ.m old mode 100755 new mode 100644 index e148605..5e08155 --- a/VPRJ.m +++ b/VPRJ.m @@ -1,5 +1,4 @@ VPRJ ;SLC/KCM -- Menu for JSON data store utilities - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; ; Menu to run various utilities for the JSON data store: D ^VPRJ ; @@ -7,19 +6,26 @@ G DOMENU^VPRJ1 ; START ; Start the HTTP listener - I $$STATUS^VPRJRCL="running" W !,"Listener is already running.",! Q - ; - W !,"Starting listener on port ",$$PORT^VPRJRCL - D GO^VPRJRCL + N PORTS + S PORTS=$$PORT^VPRJRCL + W !,"Starting listener on ports "_PORTS + F I=1:1:$L(PORTS," ") D GO^VPRJRCL($P(PORTS," ",I)) H 1 W !,"Listener status: ",$$STATUS^VPRJRCL,! - Q + ; + QUIT + ; STOP ; Stop the HTTP listener - N X - I $G(^VPRHTTP(0,"listener"))="stopped" W !,"Listener is already stopped.",! Q + N X,NUM,STAT + S NUM="" + S STAT="stopped" + F S NUM=$O(^VPRHTTP(NUM)) Q:NUM'=+NUM D + . I $D(^VPRHTTP(NUM,"listener"))#2,^VPRHTTP(NUM,"listener")'="stopped" S STAT=$G(^VPRHTTP(NUM,"listener")) + I STAT="stopped" W !,"Listeners are already stopped.",! QUIT D STOPW^VPRJRCL - Q -WAIT ; + QUIT + ; +WAIT ; NOT USED - also needs to be reworked for multi-listener support N I,X S X=$$STATUS^VPRJRCL W !,"Listener status: ",X @@ -29,16 +35,30 @@ . W "." . I X="stopped" W X Q -PORT ; Change the listening port number +ADDPORT ; Add a listener port number N PORT W !,"Enter port number: " R PORT:300 E Q I '$L(PORT) Q - I (PORT<1024)!(PORT>65000) W " ??" G PORT + I (PORT<1024)!(PORT>65000) W " ??" G ADDPORT D STOP D SPORT^VPRJRCL(PORT) + W !,"Added listener port: "_PORT,! D START - Q + QUIT + ; +REMOVEPORT ; Remove a listener port number + N PORT + W !,"Enter port number: " + R PORT:300 E Q + I '$L(PORT) Q + I (PORT<1024)!(PORT>65000) W " ??" G REMOVEPORT + D STOP + D RPORT^VPRJRCL(PORT) + W !,"Removed listener port: "_PORT,! + D START + QUIT + ; LOG ; Set the logging level N X W !,"Log level will be changed on the next connection.",! @@ -149,7 +169,7 @@ D LISTPTS(0) Q FULLRBLD ; do a full rebuild of VPR and non-patient data D SUSPEND - K ^TMP($J) + K:$D(^||TMP($J)) ^||TMP($J) D RBLDALL^VPRJ2P D RBLDALL^VPRJ2D D RESUME @@ -157,35 +177,34 @@ D LISTPTS(0) FULLRSET ; reset (delete data and re-init) for VPR and non-patient data N NMPORT D SUSPEND - K ^TMP($J) + K:$D(^||TMP($J)) ^||TMP($J) D KILLDB^VPRJ2P D KILLDB^VPRJ2D D SETUP^VPRJCONFIG D RESUME - ;BL eHMP may require multiple ports. Store ports in VPRHTTP(X,"port") and restart - I $G(^VPRHTTP(1,"port")) D - . N PORT - . S NMPORT=0 - . F S NMPORT=$O(^VPRHTTP(NMPORT)) Q:NMPORT'=+NMPORT D - . . S PORT=^VPRHTTP(NMPORT,"port") - . . W !,"Restarting HTTP Listener on Port "_PORT - . . D GO^VPRJRCL(PORT) - Q + QUIT + ; SUSPEND ; suspend listener and set updating flag S ^VPRHTTP(0,"updating")=1 - I $E($G(^VPRHTTP(0,"listener")),1,4)'="stop" D + N NUM + S NUM="" + F S NUM=$O(^VPRHTTP(NUM)) Q:NUM'=+NUM I $D(^VPRHTTP(NUM,"listener"))#2,$E(^VPRHTTP(NUM,"listener"),1,4)'="stop" D Q . S ^VPRHTTP(0,"updating","resume")=1 - . W !,"Suspending HTTP Listener..." + . W !,"Suspending HTTP Listeners..." D STOPW^VPRJRCL - Q + QUIT + ; RESUME ; resume listener if it was running before and reset updating flag N RESUME S RESUME=$G(^VPRHTTP(0,"updating","resume"),0) - K ^VPRHTTP(0,"updating") + K:$D(^VPRHTTP(0,"updating")) ^VPRHTTP(0,"updating") I RESUME D - . W !,"Restarting HTTP Listener..." - . D GO^VPRJRCL - Q + . N PORTS + . S PORTS=$$PORT^VPRJRCL + . W !,"Restarting listener on ports "_PORTS + . F I=1:1:$L(PORTS," ") D GO^VPRJRCL($P(PORTS," ",I)) + QUIT + ; ISYES(MSG) ; returns 1 if user answers yes to message, otherwise 0 N X W !,MSG diff --git a/VPRJ1.m b/VPRJ1.m old mode 100755 new mode 100644 index ac82da9..fafeba7 --- a/VPRJ1.m +++ b/VPRJ1.m @@ -1,5 +1,4 @@ VPRJ1 ;SLC/KCM -- Menu Handling for JSON Store Utilities - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; DOMENU ; display menu and execute choice N SEL @@ -12,14 +11,16 @@ . I SEL="PORT^VPRJ" D HEADER . I SEL="DELPID^VPRJ" D HEADER Q + ; HEADER ; display header information W ! - W "Listener Port: ",$$PORT^VPRJRCL," " - W "Status: ",$$STATUS^VPRJRCL," " + W "Listener Ports: ",$$PORT^VPRJRCL,! + W "Status: ",$$STATUS^VPRJRCL,! W "Log Level: ",$$LOG^VPRJRCL," " - W "VPR Patients: ",$G(^VPRPTX("count","patient","patient")) + W "VPR Patients: ",$G(^VPRPTX("count","patient","patient"),0) W ! - Q + QUIT + ; SHOWMENU ; display menu N X,I S I=0 F S I=I+1,X=$P($T(MENULST+I),";;",2,99) Q:X="zzzzz" W !,X @@ -53,9 +54,10 @@ Q MENULST ;; menu display list ;;-- Listener -- -- Logging -- - ;; 1 Start HTTP Listener on Port 9080 4 Change Logging Level - ;; 2 Stop HTTP Listener 5 Clear Logs - ;; 3 Change HTTP Listener Port 6 List Errors + ;; 1 Start HTTP Listeners 5 Change Logging Level + ;; 2 Stop HTTP Listeners 6 Clear Logs + ;; 3 Add HTTP Listener Port 7 List Errors + ;; 4 Remove HTTP Listener Port ;; ;;-- VPR Info -- -- ODC Info -- ;;11 List Synced Patients (alpha) 21 List Collections (ODC) @@ -74,21 +76,22 @@ MENUNUM ;; menu selection numbers ;;1;START^VPRJ ;;2;STOP^VPRJ - ;;3;PORT^VPRJ - ;;4;LOG^VPRJ - ;;5;CLEAR^VPRJ - ;;6;ERROR^VPRJ + ;;3;ADDPORT^VPRJ + ;;4;REMOVEPORT^VPRJ + ;;5;LOG^VPRJ + ;;6;CLEAR^VPRJ + ;;7;ERROR^VPRJ ;;11;LISTPTA^VPRJ ;;12;LISTPTP^VPRJ ;;13;PIDSTAT^VPRJ ;;14;STATUS^VPRJ2P ;;21;LSTCTN^VPRJ2D ;;22;STATUS^VPRJ2D - ;;31;RIDXALL^VPRJ2P + ;;31;RIDX^VPRJ2P ;;32;RBLDALL^VPRJ2P ;;33;DELPID^VPRJ ;;34;RESET^VPRJ - ;;41;RIDXALL^VPRJ2D + ;;41;RIDX^VPRJ2D ;;42;RBLDALL^VPRJ2D ;;43;DELCTN^VPRJ2D ;;44;RESET^VPRJ2D diff --git a/VPRJ2D.m b/VPRJ2D.m old mode 100755 new mode 100644 index 19f2b0d..42531f1 --- a/VPRJ2D.m +++ b/VPRJ2D.m @@ -1,31 +1,75 @@ VPRJ2D ;SLC/KCM -- Management utilities for JSON objects - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; -RIDXALL ; Reindex data - N OK,KEY - K ^XTMP("VPRJVUP","odc") +RIDX ; Re-index all operational data, giving an option to re-index all indexes, or a list of possible indexes + D SETUP^VPRJPMD ; Rebuild the meta data to pick up new indexes from VPRJDMX + N YESNO + R !,"Would you like to re-index every index? (Y/N - defaults to N): ",YESNO + S YESNO=$TR(YESNO,"yesno","YESNO") + W !! + I YESNO'="","YES"[YESNO W !,"Re-indexing operational data for all indexes...",! D RIDXALL QUIT + E D + . N CNT,KEY,COLL,IDX,IDXLIST,INDEX,INDEXES,LABEL,I,LINE,DESC,LN + . S INDEX="" + . W ! + . F LABEL="IDXTALLY","IDXATTR" D + . . F I=1:1 S LINE=$P($T(@LABEL+I^VPRJDMX),";;",2,99) Q:LINE["zzzzz" I $E(LINE)'=" " S INDEXES(LINE)="" + . . S CNT=0,(IDX,LN)="",DESC=$P($T(@LABEL^VPRJDMX),";",2,99) + . . W DESC,! S $P(LN,"-",$L(DESC))="" W LN_"--",! + . . F S IDX=$O(INDEXES(IDX)) Q:IDX="" W $J(IDX,25) S CNT=CNT+1 W:CNT#3=0 ! + . . W:CNT#3'=0 ! + . . W ! + . . K INDEXES + . W !,"Select the names of the indexes that you want to re-index, then hit ",! + . W "Hit again when you are finished, or Q if you want to quit without running",! + . F R !,"Enter index name: ",IDXLIST Q:(IDXLIST="")!($TR(IDXLIST,"q","Q")="Q") D + . . S INDEX=INDEX_","_IDXLIST + . I $TR(IDXLIST,"q","Q")="Q" W ! Q + . S $E(INDEX)="" + . I INDEX="" W !,"Nothing to re-index, quitting...",! Q + . E W !,"Re-indexing operational data for the chosen index(es): "_$TR(INDEX,","," "),! + . D RIDXALL(INDEX) + QUIT + ; +RIDXALL(INDEX) ; Re-index all operational data + ; @param {string} [INDEX=""] - A list of one or more comma-delimited index names to re-index, or if omitted or empty, re-index all + N OK,KEY,NUM,FLG + K:$D(^XTMP("VPRJVUP","odc")) ^XTMP("VPRJVUP","odc") S ^XTMP("VPRJVUP","odc","total")=$$TOTCTNI() D LOGMSG^VPRJ("odc","Re-indexing all non-patient data") - L +^VPRJD:$G(^VPRCONFIG("timeout","odindex"),5) E D LOGMSG^VPRJ("odc","Unable to lock all operational data") Q + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRJD:$G(^VPRCONFIG("timeout","odindex"),5) E D LOGMSG^VPRJ("odc","Unable to lock all operational data") QUIT D SUSPEND^VPRJ - D CLRINDEX(.OK) Q:'OK + S NUM=0,FLG=0 + F S NUM=$O(^VPRHTTP(NUM)) Q:(NUM'=+NUM)!FLG D + . I (($D(^VPRHTTP(NUM,"listener"))#2)&(^VPRHTTP(NUM,"listener")'="stopped"))!($D(^VPRHTTP(0,"child"))'=0) D + . . W "Unable to re-index operational data at this time.." + . . D RESUME^VPRJ + . . ; Disabling global lock (cf. WRC 880083) + . . ; L -^VPRJD + . . S FLG=1 + I FLG QUIT + D CLRINDEX(.OK,$G(INDEX)) QUIT:'OK + ; S KEY="" F S KEY=$O(^VPRJD(KEY)) Q:KEY="" D - . D RIDXOBJ(KEY) + . D RIDXOBJ(KEY,$G(INDEX)) . D LOGCNT^VPRJ("odc") D RESUME^VPRJ - L -^VPRJD + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRJD S ^XTMP("VPRJVUP","odc","complete")=1 - Q -RIDXCTN(CTN) ; Reindex a collection + QUIT + ; +RIDXCTN(CTN) ; Re-index a collection ; Can't re-index an object at a time without corrupting the tallys ; We don't know which tallies to kill. Q RBLDALL ; Rebuild all objects (includes templates) N OK,KEY - K ^XTMP("VPRJVUP","odc") + K:$D(^XTMP("VPRJVUP","odc")) ^XTMP("VPRJVUP","odc") S ^XTMP("VPRJVUP","odc","total")=$$TOTCTNI() D LOGMSG^VPRJ("odc","Rebuild ALL non-patient data (including templates)") - L +^VPRJD:$G(^VPRCONFIG("timeout","odbuild"),5) E D LOGMSG^VPRJ("odc","Unable to lock ALL operational data") + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRJD:$G(^VPRCONFIG("timeout","odbuild"),5) E D LOGMSG^VPRJ("odc","Unable to lock ALL operational data") D SUSPEND^VPRJ D CLRINDEX(.OK) Q:'OK ; clears VPRJDX,VPRTMP D CLRDATA(.OK) Q:'OK ; clears VPRJD,VPRJDJ except VPRJDJ("JSON") @@ -33,7 +77,8 @@ D CLRINDEX(.OK) Q:'OK . D RBLDOBJ(KEY) . D LOGCNT^VPRJ("odc") D RESUME^VPRJ - L -^VPRJD + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRJD D LOGMSG^VPRJ("odc","ODC rebuild complete") S ^XTMP("VPRJVUP","odc","complete")=1 Q @@ -41,16 +86,23 @@ D CLRINDEX(.OK) Q:'OK ; Can't re-buld an object at a time without corrupting the tallys ; We don't know which tallies to kill. Q -RIDXOBJ(KEY) ; Re-index a single object - L +^VPRJD(KEY):$G(^VPRCONFIG("timeout","odindex"),5) E D LOGMSG^VPRJ("odc","Unable to obtain lock for "_KEY) QUIT - N OBJECT,STAMP +RIDXOBJ(KEY,INDEX) ; Re-index a single object + ; @param {string} KEY - The identifier (UID) of the operational data item + ; @param {string} [INDEX=""] - A list of one or more comma-delimited index names to re-index, or if omitted or empty, re-index all + N OBJECT,STAMP,LTP + ; Using ECP with a lot of data, locking and using transactions around the re-indexing code might have a performance penalty + ; Check to see if we should wrap this with a lock and a transaction in this environment + S LTP=$G(^VPRCONFIG("reindexLockTransactions"),0) + I LTP L +^VPRJD(KEY):$G(^VPRCONFIG("timeout","odindex"),5) E D LOGMSG^VPRJ("odc","Unable to obtain lock for "_KEY) QUIT S STAMP=$O(^VPRJD(KEY,""),-1) + I STAMP="" W "KEY: "_KEY_" HAS NO EVENTSTAMP",! L:LTP -^VPRJD(KEY) QUIT M OBJECT=^VPRJD(KEY,STAMP) - TSTART - D INDEX^VPRJDX(KEY,"",.OBJECT) - TCOMMIT - L -^VPRJD(KEY) - Q + I LTP TSTART + D INDEX^VPRJDX(KEY,"",.OBJECT,$G(INDEX)) + I LTP TCOMMIT + I LTP L -^VPRJD(KEY) + QUIT + ; RBLDOBJ(KEY) ; Re-build a single object L +^VPRJD(KEY):$G(^VPRCONFIG("timeout","odbuild"),5) E D LOGMSG^VPRJ("odc","Unable to obtain lock for "_KEY) QUIT N LINE,JSON,STAMP @@ -58,24 +110,38 @@ D CLRINDEX(.OK) Q:'OK ; get the original JSON object without the templates S LINE=0 F S LINE=$O(^VPRJDJ("JSON",KEY,STAMP,LINE)) Q:'LINE S JSON(LINE)=^VPRJDJ("JSON",KEY,STAMP,LINE) ; indexes have been killed for whole patient, so remove the original object - K ^VPRJD(KEY) - K ^VPRJDJ("JSON",KEY) - K ^VPRJDJ("TEMPLATE",KEY) + K:$D(^VPRJD(KEY)) ^VPRJD(KEY) + K:$D(^VPRJDJ("JSON",KEY)) ^VPRJDJ("JSON",KEY) + K:$D(^VPRJDJ("TEMPLATE",KEY)) ^VPRJDJ("TEMPLATE",KEY) ; call save the replace the object & reset indexes D SAVE^VPRJDS(.JSON) L -^VPRJD(KEY) Q -CLRINDEX(OK) ; Clear all the indexes - L +^VPRJD:$G(^VPRCONFIG("timeout","odindex"),5) E D LOGMSG^VPRJ("odc","Unable to get lock for indexes.") S OK=0 Q - K ^VPRJDX,^VPRTMP - L -^VPRJD + ; +CLRINDEX(OK,INDEX) ; Clear all the indexes + ; @param {string} {required} OK (passed by reference) - A return flag that signals whether indexes were cleared of data + ; @param {string} {optional} INDEX - A list of one or more comma-delimited index names to clear from the indexes + ; If not passed, or the empty string, all indexes defined in VPRJPDX will be cleared + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRJD:$G(^VPRCONFIG("timeout","odindex"),5) E D LOGMSG^VPRJ("odc","Unable to get lock for indexes.") S OK=0 QUIT + I $G(INDEX)'="" D + . N IDX + . S IDX="" F S IDX=$O(^VPRJDX("attr",IDX)) Q:IDX="" I (","_INDEX_",")[IDX D + . . K:$D(^VPRJDX("attr",IDX)) ^VPRJDX("attr",IDX) + . K:$D(^VPRJDX("count","collection")) ^VPRJDX("count","collection") K:$D(^VPRJDX("tally","collection")) ^VPRJDX("tally","collection") K:$D(^VPRTMP) ^VPRTMP + E K:$D(^VPRJDX) ^VPRJDX K:$D(^VPRTMP) ^VPRTMP + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRJD D SETUP^VPRJPMD S OK=1 - Q + QUIT + ; CLRDATA(OK) ; Clear data except for original JSON - L +^VPRJD:$G(^VPRCONFIG("timeout","odclear"),5) E D LOGMSG^VPRJ("odc","Unable to get lock for data.") S OK=0 Q - K ^VPRJD,^VPRJDJ("TEMPLATE") - L -^VPRJD + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRJD:$G(^VPRCONFIG("timeout","odclear"),5) E D LOGMSG^VPRJ("odc","Unable to get lock for data.") S OK=0 Q + K:$D(^VPRJD) ^VPRJD K:$D(^VPRJDJ("TEMPLATE")) ^VPRJDJ("TEMPLATE") + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRJD S OK=1 Q LSTCTN ; List collections @@ -135,9 +201,12 @@ D CLRINDEX(.OK) Q:'OK D RESUME^VPRJ Q KILLDB ; -- Delete and reset the globals for the database - K ^VPRJD - K ^VPRJDJ - K ^VPRJDX - K ^VPRTMP + K:$D(^VPRJD) ^VPRJD + K:$D(^VPRJDJ) ^VPRJDJ + K:$D(^VPRJDX) ^VPRJDX + K:$D(^VPRTMP) ^VPRTMP + K:$D(^VPRSTATUSOD) ^VPRSTATUSOD + K:$D(^VPRJSES) ^VPRJSES + K:$D(^VPRJODM) ^VPRJODM D SETUP^VPRJPMD Q diff --git a/VPRJ2P.m b/VPRJ2P.m old mode 100755 new mode 100644 index df661f9..5cebd21 --- a/VPRJ2P.m +++ b/VPRJ2P.m @@ -1,46 +1,92 @@ VPRJ2P ;SLC/KCM -- Management utilities for JSON patient objects - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; -RIDXALL ; Reindex all patients - N OK,JPID,PID,KEY - K ^XTMP("VPRJVUP","vpr") +RIDX ; Re-index all patients, giving an option to re-index all indexes, or a list of possible indexes + N YESNO + R !,"Would you like to re-index every index? (Y/N - defaults to N): ",YESNO + S YESNO=$TR(YESNO,"yesno","YESNO") + W !! + I YESNO'="","YES"[YESNO W !,"Re-indexing patient data for all indexes...",! D RIDXALL QUIT + E D + . N CNT,JPID,PID,KEY,COLL,IDX,IDXLIST,INDEX,INDEXES,LABEL,I,LINE,DESC,LN + . S INDEX="" + . W ! + . F LABEL="IDXLIST","IDXTALLY","IDXTIME","IDXATTR","IDXMATCH","XIDXATTR" D + . . F I=1:1 S LINE=$P($T(@LABEL+I^VPRJPMX),";;",2,99) Q:LINE["zzzzz" I $E(LINE)'=" " S INDEXES(LINE)="" + . . S CNT=0,(IDX,LN)="",DESC=$P($T(@LABEL^VPRJPMX),";",2,99) + . . W DESC,! S $P(LN,"-",$L(DESC))="" W LN_"--",! + . . F S IDX=$O(INDEXES(IDX)) Q:IDX="" W $J(IDX,25) S CNT=CNT+1 W:CNT#3=0 ! + . . W:CNT#3'=0 ! + . . W ! + . . K INDEXES + . W !,"Select the names of the indexes that you want to re-index, then hit ",! + . W "Hit again when you are finished, or Q if you want to quit without running",! + . F R !,"Enter index name: ",IDXLIST Q:(IDXLIST="")!($TR(IDXLIST,"q","Q")="Q") D + . . S INDEX=INDEX_","_IDXLIST + . I $TR(IDXLIST,"q","Q")="Q" W ! Q + . S $E(INDEX)="" + . I INDEX="" W !,"Nothing to re-index, quitting...",! Q + . E W !,"Re-indexing patient data for the chosen index(es): "_$TR(INDEX,","," "),! + . D RIDXALL(INDEX) + QUIT + ; +RIDXALL(INDEX) ; Re-index all patients + ; @param {string} [INDEX=""] - A list of one or more comma-delimited index names to re-index, or if omitted or empty, re-index all + N OK,JPID,PID,KEY,NUM,FLG,VPRMETA + K:$D(^XTMP("VPRJVUP","vpr")) ^XTMP("VPRJVUP","vpr") S ^XTMP("VPRJVUP","vpr","total")=$G(^VPRPTX("count","patient","patient")) D LOGMSG^VPRJ("vpr","Re-indexing VPR for ALL patients") - L +^VPRPT:$G(^VPRCONFIG("timeout","ptindex"),5) E D LOGMSG^VPRJ("vpr","Unable to lock ALL patient data") Q + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRPT:$G(^VPRCONFIG("timeout","ptindex"),5) E D LOGMSG^VPRJ("vpr","Unable to lock ALL patient data") QUIT D SUSPEND^VPRJ - D CLRINDEX(.OK) Q:'OK + S NUM=0,FLG=0 + F S NUM=$O(^VPRHTTP(NUM)) Q:(NUM'=+NUM)!FLG D + . I (($D(^VPRHTTP(NUM,"listener"))#2)&(^VPRHTTP(NUM,"listener")'="stopped"))!($D(^VPRHTTP(0,"child"))'=0) D + . . W "Unable to re-index patient data at this time.." + . . D RESUME^VPRJ + . . ; Disabling global lock (cf. WRC 880083) + . . ; L -^VPRPT + . . S FLG=1 + I FLG QUIT + D CLRINDEX(.OK,$G(INDEX)) QUIT:'OK ; S JPID="" F S JPID=$O(^VPRPT(JPID)) Q:JPID="" D . S PID="" F S PID=$O(^VPRPT(JPID,PID)) Q:PID="" D - . . S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" D RIDXOBJ(PID,KEY) + . . S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" D RIDXOBJ(PID,KEY,$G(INDEX)) + . . S ^VPRPTI(JPID,PID,"every","every")=$H ; timestamps latest re-index for this PID . . D LOGCNT^VPRJ("vpr") D RESUME^VPRJ - L -^VPRPT + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRPT S ^XTMP("VPRJVUP","vpr","complete")=1 - Q -RIDXPID(PID) ; Reindex a single patient - N JPID,KEY + QUIT + ; +RIDXPID(PID) ; Re-index a single patient + N JPID,KEY,LTP ; - K ^XTMP("VPRJVUP","vpr") + K:$D(^XTMP("VPRJVUP","vpr")) ^XTMP("VPRJVUP","vpr") D LOGMSG^VPRJ("vpr","Re-index VPR for a single patient") Q:'$L($G(PID)) ; S JPID=$$JPID4PID^VPRJPR(PID) I JPID="" D LOGMSG^VPRJ("vpr","Unable to acquire JPID for PID: "_PID) Q ; - L +^VPRPT(JPID,PID):$G(^VPRCONFIG("timeout","ptindex"),5) E D LOGMSG^VPRJ("vpr","Unable to lock patient data") Q + ; Using ECP with a lot of data, locking and using transactions around the re-indexing code might have a performance penalty + ; Check to see if we should wrap this with a lock and a transaction in this environment + S LTP=$G(^VPRCONFIG("reindexLockTransactions"),0) + I LTP L +^VPRPT(JPID,PID):$G(^VPRCONFIG("timeout","ptindex"),5) E D LOGMSG^VPRJ("vpr","Unable to lock patient data") Q D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) - K ^VPRPTI(JPID,PID) + K:$D(^VPRPTI(JPID,PID)) ^VPRPTI(JPID,PID) S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" D RIDXOBJ(PID,KEY) - L -^VPRPT(JPID,PID) + I LTP L -^VPRPT(JPID,PID) Q ; RBLDALL ; Rebuild all patients (includes templates) N OK,JPID,OPID - K ^XTMP("VPRJVUP","vpr") + K:$D(^XTMP("VPRJVUP","vpr")) ^XTMP("VPRJVUP","vpr") S ^XTMP("VPRJVUP","vpr","total")=$G(^VPRPTX("count","patient","patient")) D LOGMSG^VPRJ("vpr","Re-build VPR (including templates) for ALL patients") - L +^VPRPT:$G(^VPRCONFIG("timeout","ptbuild"),5) E D LOGMSG^VPRJ("vpr","Unable to lock ALL patient data") Q + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRPT:$G(^VPRCONFIG("timeout","ptbuild"),5) E D LOGMSG^VPRJ("vpr","Unable to lock ALL patient data") Q D SUSPEND^VPRJ D CLRINDEX(.OK) Q:'OK ; clears VPRPTI,VPRPTX,VPRTMP D CLRDATA(.OK) Q:'OK ; clears VPRPT,VPRPTJ except VPRPTJ("JSON") @@ -54,7 +100,8 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) . . S KEY="" F S KEY=$O(^VPRPTJ("JSON",JPID,OPID,KEY)) Q:KEY="" D RBLDOBJ(OPID,KEY) . . D LOGCNT^VPRJ("vpr") D RESUME^VPRJ - L -^VPRPT + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRPT D LOGMSG^VPRJ("vpr","VPR rebuild complete") S ^XTMP("VPRJVUP","vpr","complete")=1 Q @@ -71,7 +118,7 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) RBLDPID(PID) ; Rebuild single patient (includes templates) N JPID,KEY ; - K ^XTMP("VPRJVUP","vpr") + K:$D(^XTMP("VPRJVUP","vpr")) ^XTMP("VPRJVUP","vpr") D LOGMSG^VPRJ("vpr","Re-build VPR (including templates) for a single patient") Q:'$L($G(PID)) ; @@ -80,24 +127,32 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) ; L +^VPRPT(JPID,PID):$G(^VPRCONFIG("timeout","ptbuild"),5) E D LOGMSG^VPRJ("vpr","Unable to lock patient data") Q D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) - K ^VPRPTI(JPID,PID) + K:$D(^VPRPTI(JPID,PID)) ^VPRPTI(JPID,PID) S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" D RBLDOBJ(PID,KEY) L -^VPRPT(JPID,PID) Q -RIDXOBJ(PID,KEY) ; Re-index a single object - N JPID,OBJECT,STAMP +RIDXOBJ(PID,KEY,INDEX) ; Re-index a single object + ; @param {string} PID - The patient site identifier + ; @param {string} KEY - The identifier (UID) of the patient data event + ; @param {string} [INDEX=""] - A list of one or more comma-delimited index names to re-index, or if omitted or empty, re-index all + N JPID,OBJECT,STAMP,LTP ; S JPID=$$JPID4PID^VPRJPR(PID) - I JPID="" D LOGMSG^VPRJ("vpr","Unable to acquire JPID for PID: "_PID) Q + I JPID="" D LOGMSG^VPRJ("vpr","Unable to acquire JPID for PID: "_PID) QUIT ; - L +^VPRPT(JPID,PID,KEY):$G(^VPRCONFIG("timeout","ptindex"),5) E D LOGMSG^VPRJ("vpr","Unable to obtain lock for "_KEY) Q + ; Using ECP with a lot of data, locking and using transactions around the re-indexing code might have a performance penalty + ; Check to see if we should wrap this with a lock and a transaction in this environment + S LTP=$G(^VPRCONFIG("reindexLockTransactions"),0) + I LTP L +^VPRPT(JPID,PID,KEY):$G(^VPRCONFIG("timeout","ptindex"),5) E D LOGMSG^VPRJ("vpr","Unable to obtain lock for "_KEY) QUIT S STAMP=$O(^VPRPT(JPID,PID,KEY,""),-1) + I STAMP="" W "PID: "_PID_"; UID: "_KEY_" HAS NO EVENTSTAMP",! L:LTP -^VPRPT(JPID,PID,KEY) QUIT M OBJECT=^VPRPT(JPID,PID,KEY,STAMP) - TSTART - D INDEX^VPRJPX(PID,KEY,"",.OBJECT) - TCOMMIT - L -^VPRPT(JPID,PID,KEY) - Q + I LTP TSTART + D INDEX^VPRJPX(PID,KEY,"",.OBJECT,$G(INDEX)) + I LTP TCOMMIT + I LTP L -^VPRPT(JPID,PID,KEY) + QUIT + ; RBLDOBJ(PID,KEY) ; Re-build a single object N LINE,JSON,STAMP ; @@ -110,30 +165,53 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) S LINE=0 F S LINE=$O(^VPRPTJ("JSON",JPID,PID,KEY,STAMP,LINE)) Q:'LINE D . S JSON(LINE)=^VPRPTJ("JSON",JPID,PID,KEY,STAMP,LINE) ; indexes have been killed for whole patient, so remove the original object - K ^VPRPT(JPID,PID,KEY) - K ^VPRPTJ("JSON",JPID,PID,KEY) - K ^VPRPTJ("TEMPLATE",JPID,PID,KEY) - K ^VPRPTJ("KEY",KEY,PID) + K:$D(^VPRPT(JPID,PID,KEY)) ^VPRPT(JPID,PID,KEY) + K:$D(^VPRPTJ("JSON",JPID,PID,KEY)) ^VPRPTJ("JSON",JPID,PID,KEY) + K:$D(^VPRPTJ("TEMPLATE",JPID,PID,KEY)) ^VPRPTJ("TEMPLATE",JPID,PID,KEY) + K:$D(^VPRPTJ("KEY",KEY,PID)) ^VPRPTJ("KEY",KEY,PID) ; call save the replace the object & reset indexes D SAVE^VPRJPS(JPID,.JSON) L -^VPRPT(JPID,PID,KEY) Q -CLRINDEX(OK) ; Clear all the indexes, preserving the "put patient" part - ; since that is not redone with a reindex + ; +CLRINDEX(OK,INDEX) ; Clear all the indexes, preserving the "put patient" part, since that is not redone with a re-index + ; @param {string} {required} OK (passed by reference) - A return flag that signals whether indexes were cleared of data + ; @param {string} {optional} INDEX - A list of one or more comma-delimited index names to clear from the indexes + ; If not passed, or the empty string, all indexes defined in VPRJPMX will be cleared N PCNT - L +^VPRPTJ("PID"):$G(^VPRCONFIG("timeout","ptclear"),5) E D LOGMSG^VPRJ("vpr","Unable to get lock for indexes.") S OK=0 Q + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRPTJ("PID"):$G(^VPRCONFIG("timeout","ptclear"),5) E D LOGMSG^VPRJ("vpr","Unable to get lock for indexes.") S OK=0 QUIT S PCNT=$G(^VPRPTX("count","patient","patient"),0) - K ^VPRPTI,^VPRPTX,^VPRTMP + I $G(INDEX)'="" D + . N JPID,PID,IDX + . S JPID="" F S JPID=$O(^VPRPTI(JPID)) Q:JPID="" D + . . S PID="" F S PID=$O(^VPRPTI(JPID,PID)) Q:PID="" D + . . . S IDX="" F S IDX=$O(^VPRPTI(JPID,PID,"attr",IDX)) Q:IDX="" I (","_INDEX_",")[IDX D + . . . . K:$D(^VPRPTI(JPID,PID,"attr",IDX)) ^VPRPTI(JPID,PID,"attr",IDX) K:$D(^VPRPTX("xattr",IDX)) ^VPRPTX("xattr",IDX) + . . . K:$D(^VPRPTI(JPID,PID,"tally","collection")) ^VPRPTI(JPID,PID,"tally","collection") K:$D(^VPRPTI(JPID,PID,"tally","domain")) ^VPRPTI(JPID,PID,"tally","domain") + . K:$D(^VPRPTX("count")) ^VPRPTX("count") K:$D(^VPRTMP) ^VPRTMP + E D + . I $ZV["Cache" D + . . D KILLSHARD("VPRPTI") + . E D + . . K:$D(^VPRPTI) ^VPRPTI + . ; Common unsharded globals + . K:$D(^VPRPTX) ^VPRPTX + . K:$D(^VPRTMP) ^VPRTMP S ^VPRPTX("count","patient","patient")=PCNT ; preserve the count - L -^VPRPTJ("PID") + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRPTJ("PID") D SETUP^VPRJPMD S OK=1 - Q + QUIT + ; CLRDATA(OK) ; Clear all data except for original JSON - L +^VPRPTJ("PID"):$G(^VPRCONFIG("timeout","ptclear"),5) E D LOGMSG^VPRJ("vpr","Unable to get lock for data.") S OK=0 Q - K ^VPRPT,^VPRPTJ("TEMPLATE"),^VPRPTJ("KEY"),^VPRPTJ("PID") - K ^VPRPTX("count","patient","patient") ; remove since total rebuild - L -^VPRPTJ("PID") + ; Disabling global lock (cf. WRC 880083) + ; L +^VPRPTJ("PID"):$G(^VPRCONFIG("timeout","ptclear"),5) E D LOGMSG^VPRJ("vpr","Unable to get lock for data.") S OK=0 Q + K:$D(^VPRPT) ^VPRPT K:$D(^VPRPTJ("TEMPLATE")) ^VPRPTJ("TEMPLATE") K:$D(^VPRPTJ("KEY")) ^VPRPTJ("KEY") K:$D(^VPRPTJ("PID")) ^VPRPTJ("PID") + K:$D(^VPRPTX("count","patient","patient")) ^VPRPTX("count","patient","patient") ; remove since total rebuild + ; Disabling global lock (cf. WRC 880083) + ; L -^VPRPTJ("PID") S OK=1 Q CLRCODES(PID) ; Clear the cross patient indexes for coded values @@ -143,22 +221,22 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) S FLD="" F S FLD=$O(^VPRPTX("pidCodes",PID,FLD)) Q:FLD="" D . S CODE="" F S CODE=$O(^VPRPTX("pidCodes",PID,FLD,CODE)) Q:CODE="" D . . S KEY="" F S KEY=$O(^VPRPTX("pidCodes",PID,FLD,CODE,KEY)) Q:KEY="" D - . . . K ^VPRPTX("allCodes",CODE,FLD,PID,KEY) - K ^VPRPTX("pidCodes",PID) + . . . K:$D(^VPRPTX("allCodes",CODE,FLD,PID,KEY)) ^VPRPTX("allCodes",CODE,FLD,PID,KEY) + K:$D(^VPRPTX("pidCodes",PID)) ^VPRPTX("pidCodes",PID) Q CLREVIEW(PID) ; Clear the cross patient indexes for re-evaluation times ;remove ^VPRPTX("review",reviewTime,PID) ;remove ^VPRPTX("pidReview",PID) N REVTM S REVTM="" F S REVTM=$O(^VPRPTX("pidReview",PID,REVTM)) Q:REVTM="" D - . K ^VPRPTX("review",REVTM,PID) - K ^VPRPTX("pidReview",PID) + . K:$D(^VPRPTX("review",REVTM,PID)) ^VPRPTX("review",REVTM,PID) + K:$D(^VPRPTX("pidReview",PID)) ^VPRPTX("pidReview",PID) Q CLRCOUNT(PID) ; Decrement the cross-patient totals for a patient ;reduce ^VPRPTX("count","collection",topic) - ; by ^VPRPTI(PID,"tally","collection",topic) + ; by ^VPRPTI(JPID,PID,"tally","collection",topic) ;reduce ^VPRPTX("count","domain",topic) - ; by ^VPRPTI(PID,"tally","domain",topic) + ; by ^VPRPTI(JPID,PID,"tally","domain",topic) N GROUP,TOPIC,CNT4PID,CNT4ALL,JPID ; decrement the relevant counts ; S JPID=$$JPID4PID^VPRJPR(PID) @@ -172,18 +250,22 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) . . S ^VPRPTX("count",GROUP,TOPIC)=CNT4ALL-CNT4PID ; decr count across patients . . L -^VPRPTX("count",GROUP,TOPIC) Q + ; CLRXIDX(PID) ; remove cross-patient indexes for a patient - N KEY,OLDOBJ,JPID + N KEY,OLDOBJ,JPID,STAMP ; S JPID=$$JPID4PID^VPRJPR(PID) - I JPID="" D SETERROR^VPRJRER(222,"Identifier "_PID) Q + I JPID="" D SETERROR^VPRJRER(222,"Identifier "_PID) QUIT ; S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:'$L(KEY) D . L +^VPRPT(JPID,PID,KEY):$G(^VPRCONFIG("timeout","ptclear"),5) E D SETERROR^VPRJRER(502,PID_"> "_KEY) Q - . M OLDOBJ=^VPRPT(JPID,PID,KEY) + . S STAMP=$O(^VPRPT(JPID,PID,KEY,""),-1) + . I STAMP="" D SETERROR^VPRJRER(228,PID_"> "_KEY) L -^VPRPT(JPID,PID,KEY) Q + . M OLDOBJ=^VPRPT(JPID,PID,KEY,STAMP) . D CLRXONE(PID,KEY,.OLDOBJ) . L -^VPRPT(JPID,PID,KEY) - Q + QUIT + ; CLRXONE(PID,KEY,OLDOBJ) ; Clear cross-patient indexes for this key N IDXCOLL,IDXNAME,NEWOBJ ; Currently assuming UID is urn:va:type:vistaAccount:localId... @@ -269,18 +351,24 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) Q COUNT ; KILLDB ; -- Delete and reset the globals for the database - K ^VPRHTTP("log") - K ^VPRPT - K ^VPRPTJ - K ^VPRPTI - K ^VPRPTX - K ^VPRTMP - K ^VPRMETA - K ^VPRJOB - K ^VPRSTATUS - K ^VPRSTATUSOD - K ^VPRJSES - K ^VPRJODM + N JPID + K:$D(^VPRHTTP("log")) ^VPRHTTP("log") + ; Patient data needs to be deleted by database due to sharding (Caché only) + I $ZV["Cache" D + . D KILLSHARD("VPRPT") + . D KILLSHARD("VPRPTJ") + . D KILLSHARD("VPRPTI") + . D KILLSHARD("VPRSTATUS") + E D + . K:$D(^VPRPT) ^VPRPT + . K:$D(^VPRPTJ) ^VPRPTJ + . K:$D(^VPRPTI) ^VPRPTI + . K:$D(^VPRSTATUS) ^VPRSTATUS + ; These globals are not sharded + K:$D(^VPRPTX) ^VPRPTX + K:$D(^VPRTMP) ^VPRTMP + K:$D(^VPRMETA) ^VPRMETA + K:$D(^VPRJOB) ^VPRJOB D SETUP^VPRJPMD Q ASKPID() ; Return PID after prompting for it @@ -293,3 +381,31 @@ D CLRCODES(PID),CLREVIEW(PID),CLRCOUNT(PID) I '$D(^VPRPT(JPID,PID)) W !,"PID "_PID_" not found." S PID="" Q PID ; + ; Kill possibly sharded globals (only for Caché) + ; This uses a few object script classes to get a list of databases that + ; exist on the server and blindly kills the data. There is no check to see + ; if they are mapped into the JDS namespace, so it assumes that the caché instance + ; is dedicated to a single JDS install. +KILLSHARD(GLOBAL) + N NAMESPACE,DATABASES,STATUS,DBNAME,DIRECTORY,SERVER,KILLGLOBAL + S NAMESPACE=$ZU(5) + ; Retrieve the list of databases. Only available via %SYS Namespace + ; Ran as a single line to make sure we get back to our namespace as quick as possible + ZN "%SYS" + S DATABASES=##class(%ResultSet).%New("Config.Databases:List") + S STATUS=DATABASES.Execute() + ; Iterate through all databases listed + WHILE (DATABASES.%Next()) { + S DBNAME=DATABASES.Get("Name") + S DIRECTORY=DATABASES.Get("Directory") + S SERVER=DATABASES.Get("Server") + I (DBNAME'="CACHESYS"),(DBNAME'="CACHELIB"),(DBNAME'="CACHETEMP"),(DBNAME'="CACHE"),(DBNAME'="CACHEAUDIT"),(DBNAME'="DOCBOOK"),(DBNAME'="SAMPLES") D + . ; Extended Global Reference: ^|"^SERVER"^"DIRECTORY"|GLOBAL + . ; Sample: ^|"^JDSDB1^/opt/cache/dbs/"|VPRPTJ + . I SERVER'="" S KILLGLOBAL = "^|""^"_SERVER_"^"_DIRECTORY_"""|"_GLOBAL + . E S KILLGLOBAL = "^|""^^"_DIRECTORY_"""|"_GLOBAL + . K @KILLGLOBAL + } + D DATABASES.Close() + ZN NAMESPACE + Q diff --git a/VPRJ3.m b/VPRJ3.m old mode 100755 new mode 100644 diff --git a/VPRJAQ.m b/VPRJAQ.m old mode 100755 new mode 100644 index 91ea9a2..2671a62 --- a/VPRJAQ.m +++ b/VPRJAQ.m @@ -5,7 +5,7 @@ ; return tallies as data:{items:[{"topic":"med","count":4} I '$L(CNTNM) D SETERROR^VPRJRER(101) Q N BUFFER S BUFFER="" - K ^TMP($J) + K:$D(^||TMP($J)) ^||TMP($J) ; N TOPIC,DATA,COUNT,X S DATA=0,TOPIC="" @@ -28,13 +28,13 @@ S METHOD=$G(INDEX("method")) I '$L(METHOD) D SETERROR^VPRJRER(102,INDEX) Q I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) D SETORDER^VPRJCO(.ORDER) Q:$G(HTTPERR) - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) D QATTR^VPRJAQA D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q QPID(FILTER) ; Custom query to just return all PID's (/vpr/all/index/pid/pid) - K ^TMP($J) + K:$D(^||TMP($J)) ^||TMP($J) N COUNT,PID,LINE,BUFFER,CLAUSES,SITE S FILTER=$G(FILTER) I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) @@ -45,10 +45,10 @@ . . S SITE("site")=$P(PID,";") . . I $D(CLAUSES) Q:'$$EVALAND^VPRJGQF(.CLAUSES,$NA(SITE)) ;apply filter, quit if not true . . S COUNT=COUNT+1 - . . I $L(BUFFER)>4000 S ^TMP($J,LINE)=BUFFER,LINE=LINE+1,BUFFER="" + . . I $L(BUFFER)>4000 S ^||TMP($J,LINE)=BUFFER,LINE=LINE+1,BUFFER="" . . S BUFFER=BUFFER_$S(COUNT>1:",",1:"")_""""_PID_"""" - S ^TMP($J,LINE)=BUFFER_"]}}" - S ^TMP($J,1)=$$BLDHEAD^VPRJCB(COUNT) + S ^||TMP($J,LINE)=BUFFER_"]}}" + S ^||TMP($J,1)=$$BLDHEAD^VPRJCB(COUNT) Q QFIND(COLL,ORDER,BAIL,TEMPLATE,FILTER) ; Query across patients using filter criteria N VPRDATA,CLAUSES,PREFIX,PID,KEY,JPID @@ -56,11 +56,11 @@ S VPRDATA=0 S:'BAIL BAIL=999999 I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) D SETORDER^VPRJCO(.ORDER) Q:$G(HTTPERR) - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) S JPID="" F S JPID=$O(^VPRPT(JPID)) Q:JPID="" D . S PID="" F S PID=$O(^VPRPT(JPID,PID)) Q:'$L(PID) D . . S PREFIX="urn:va:"_COLL_":",KEY=PREFIX . . F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:$E(KEY,1,$L(PREFIX))'=PREFIX D ADDONE^VPRJPQA(KEY,0) D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q diff --git a/VPRJAQA.m b/VPRJAQA.m old mode 100755 new mode 100644 index bcedde0..9b87a51 --- a/VPRJAQA.m +++ b/VPRJAQA.m @@ -11,7 +11,7 @@ ; CLAUSES: clauses to apply filter to each object ; QATTR ; return items where attribute value is in range - ; Build ^TMP("VPRDATA",$J,sortkey,sortkey,...,key,instances) with keys of objects to return + ; Build ^||TMP("VPRDATA",$J,sortkey,sortkey,...,key,instances) with keys of objects to return ; Expects: VPRDATA,METHOD,RANGE,INDEX,ORDER,CLAUSES,BAIL N START,STOP,DIR,SUB,KEY,INST D PARSERNG^VPRJCR @@ -85,17 +85,17 @@ S SUB(1)=START(1) F S SUB(1)=$$NXT1 Q:SUB(1)="" Q:SUB(1)]]STOP(1) Q:VPRDATA'< ; Expects: .ORDER,.CLAUSES I $D(CLAUSES) Q:'$$EVALAND^VPRJCF(.CLAUSES,KEY) ;apply filter, quit if not true N I,SORT,KINST - S I=0 F S I=$O(ORDER(I)) Q:'I S SORT(I)=$S(+ORDER(I):SUB(+ORDER(I)),1:$$SORTPID^VPRJPQA(I)) + S I=0 F S I=$O(ORDER(I)) Q:'I S SORT(I)=$S(+ORDER(I):SUB(+ORDER(I)),1:$$SORTPID^VPRJPQA(I)) S:ORDER(I,"nocase") SORT(I)=$$LOW^XLFSTR(SORT(I)) S VPRDATA=VPRDATA+1 ; case - I ORDER(0)=0 S ^TMP("VPRDATA",$J,KEY,INST)="" G X1 - I ORDER(0)=1 S ^TMP("VPRDATA",$J,SORT(1),KEY,INST)="" G X1 - I ORDER(0)=2 S ^TMP("VPRDATA",$J,SORT(1),SORT(2),KEY,INST)="" G X1 - I ORDER(0)=3 S ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY,INST)="" G X1 - I ORDER(0)=4 S ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY,INST)="" G X1 - I ORDER(0)=5 S ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY,INST)="" G X1 - I ORDER(0)=6 S ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY,INST)="" G X1 - I ORDER(0)=7 S ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY,INST)="" G X1 + I ORDER(0)=0 S ^||TMP("VPRDATA",$J,KEY,INST)="" G X1 + I ORDER(0)=1 S ^||TMP("VPRDATA",$J,SORT(1),KEY,INST)="" G X1 + I ORDER(0)=2 S ^||TMP("VPRDATA",$J,SORT(1),SORT(2),KEY,INST)="" G X1 + I ORDER(0)=3 S ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY,INST)="" G X1 + I ORDER(0)=4 S ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY,INST)="" G X1 + I ORDER(0)=5 S ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY,INST)="" G X1 + I ORDER(0)=6 S ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY,INST)="" G X1 + I ORDER(0)=7 S ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY,INST)="" G X1 X1 ; end case Q ; diff --git a/VPRJCB.m b/VPRJCB.m old mode 100755 new mode 100644 index 38ead4b..22e2942 --- a/VPRJCB.m +++ b/VPRJCB.m @@ -14,7 +14,7 @@ Q OUT(X) ; write out a frame of data S BUFFER("LINES")=$G(BUFFER("LINES"),0)+1 - S ^TMP($J,BUFFER("LINES"))=BUFFER,BUFFER="" + S ^||TMP($J,BUFFER("LINES"))=BUFFER,BUFFER="" Q BUILD ; Build the return records in the proper sort order ; Expects: ORDER, TEMPLATE @@ -27,63 +27,63 @@ S BUFFER("LINES")=$G(BUFFER("LINES"),0)+1 . S LASTTIME=$$CURRTIME^VPRJRUT . S ^VPRMETA("JPID",JPID,"lastAccessTime")=LASTTIME ; - S RECNUM=$G(^TMP($J,"total"))-1 ; ^TMP($J,"total") exists for index queries + S RECNUM=$G(^||TMP($J,"total"))-1 ; ^||TMP($J,"total") exists for index queries ; case I ORDER(0)=0 D G X0 - . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,KEY)) Q:KEY="" D - . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,KEY)) Q:KEY="" D + . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=1 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),KEY)) Q:KEY="" D - . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),KEY)) Q:KEY="" D + . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=2 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S SORT(2)="" F S SORT(2)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D - . . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),KEY)) Q:KEY="" D - . . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S SORT(2)="" F S SORT(2)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D + . . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),KEY)) Q:KEY="" D + . . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=3 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S SORT(2)="" F S SORT(2)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D - . . . S SORT(3)="" F S SORT(3)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D - . . . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY)) Q:KEY="" D - . . . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S SORT(2)="" F S SORT(2)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D + . . . S SORT(3)="" F S SORT(3)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D + . . . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY)) Q:KEY="" D + . . . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=4 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S SORT(2)="" F S SORT(2)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D - . . . S SORT(3)="" F S SORT(3)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D - . . . . S SORT(4)="" F S SORT(4)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D - . . . . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY)) Q:KEY="" D - . . . . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S SORT(2)="" F S SORT(2)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D + . . . S SORT(3)="" F S SORT(3)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D + . . . . S SORT(4)="" F S SORT(4)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D + . . . . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY)) Q:KEY="" D + . . . . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=5 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S SORT(2)="" F S SORT(2)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D - . . . S SORT(3)="" F S SORT(3)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D - . . . . S SORT(4)="" F S SORT(4)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D - . . . . . S SORT(5)="" F S SORT(5)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5)),ORDER(5,"dir")) Q:SORT(5)="" D - . . . . . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY)) Q:KEY="" D - . . . . . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S SORT(2)="" F S SORT(2)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D + . . . S SORT(3)="" F S SORT(3)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D + . . . . S SORT(4)="" F S SORT(4)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D + . . . . . S SORT(5)="" F S SORT(5)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5)),ORDER(5,"dir")) Q:SORT(5)="" D + . . . . . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY)) Q:KEY="" D + . . . . . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=6 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S SORT(2)="" F S SORT(2)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D - . . . S SORT(3)="" F S SORT(3)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D - . . . . S SORT(4)="" F S SORT(4)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D - . . . . . S SORT(5)="" F S SORT(5)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5)),ORDER(5,"dir")) Q:SORT(5)="" D - . . . . . . S SORT(6)="" F S SORT(6)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6)),ORDER(6,"dir")) Q:SORT(6)="" D - . . . . . . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY)) Q:KEY="" D - . . . . . . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S SORT(2)="" F S SORT(2)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D + . . . S SORT(3)="" F S SORT(3)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D + . . . . S SORT(4)="" F S SORT(4)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D + . . . . . S SORT(5)="" F S SORT(5)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5)),ORDER(5,"dir")) Q:SORT(5)="" D + . . . . . . S SORT(6)="" F S SORT(6)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6)),ORDER(6,"dir")) Q:SORT(6)="" D + . . . . . . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY)) Q:KEY="" D + . . . . . . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) I ORDER(0)=7 D G X0 - . S SORT(1)="" F S SORT(1)=$O(^TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D - . . S SORT(2)="" F S SORT(2)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D - . . . S SORT(3)="" F S SORT(3)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D - . . . . S SORT(4)="" F S SORT(4)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D - . . . . . S SORT(5)="" F S SORT(5)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5)),ORDER(5,"dir")) Q:SORT(5)="" D - . . . . . . S SORT(6)="" F S SORT(6)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6)),ORDER(6,"dir")) Q:SORT(6)="" D - . . . . . . . S SORT(7)="" F S SORT(7)=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7)),ORDER(7,"dir")) Q:SORT(7)="" D - . . . . . . . . S KEY="" F S KEY=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY)) Q:KEY="" D - . . . . . . . . . S KINST="" F S KINST=$O(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) + . S SORT(1)="" F S SORT(1)=$O(^||TMP("VPRDATA",$J,SORT(1)),ORDER(1,"dir")) Q:SORT(1)="" D + . . S SORT(2)="" F S SORT(2)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2)),ORDER(2,"dir")) Q:SORT(2)="" D + . . . S SORT(3)="" F S SORT(3)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3)),ORDER(3,"dir")) Q:SORT(3)="" D + . . . . S SORT(4)="" F S SORT(4)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4)),ORDER(4,"dir")) Q:SORT(4)="" D + . . . . . S SORT(5)="" F S SORT(5)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5)),ORDER(5,"dir")) Q:SORT(5)="" D + . . . . . . S SORT(6)="" F S SORT(6)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6)),ORDER(6,"dir")) Q:SORT(6)="" D + . . . . . . . S SORT(7)="" F S SORT(7)=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7)),ORDER(7,"dir")) Q:SORT(7)="" D + . . . . . . . . S KEY="" F S KEY=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY)) Q:KEY="" D + . . . . . . . . . S KINST="" F S KINST=$O(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY,KINST)) Q:KINST="" D ADDOBJ(^(KINST)) X0 ; end case - S ^TMP($J,"total")=RECNUM+1 ; add 1 since RECNUM is 0 based - S ^TMP($J,"template")=TEMPLATE + S ^||TMP($J,"total")=RECNUM+1 ; add 1 since RECNUM is 0 based + S ^||TMP($J,"template")=TEMPLATE Q ; ADDOBJ(VAL) ; add object/template in sequence to the return list @@ -102,5 +102,5 @@ I ORDER(0)=7 D G X0 ; adds HDR data if no associated primary data was ever found, using ADDFLG I ADDFLG D . S RECNUM=RECNUM+1 - . S ^TMP($J,"data",RECNUM,KEY,KINST)=VAL ; right now the VAL is just the PID + . S ^||TMP($J,"data",RECNUM,KEY,KINST)=VAL ; right now the VAL is just the PID Q diff --git a/VPRJCD.m b/VPRJCD.m old mode 100755 new mode 100644 index e1b3086..467b085 --- a/VPRJCD.m +++ b/VPRJCD.m @@ -12,17 +12,19 @@ . . M ^VPRMETA("collection")=METACLTN ; map collections to it . S LINES=$G(LINES)+1,LINES(LINES)=X Q -BLDSPEC(METATYPE,LINES,METADATA,METACLTN) ; build specification - ; METATYPE: index, link, or template - ;.LINES(n): contains a set of lines to parse into a specification - ;.METADATA: contains the spec to be merged into ^VPRMETA(metatype) - ;.METACLTN: contains the collection names to be merged into ^VPRMETA("collection") + ; + ; Build a specification for an index, link or template + ; @param {string} METATYPE - The string literal from the list: index, link, or template ":" then the style from the list (only for index) attr, tally, time, xattr + ; @param {array} LINES - (passed by reference) A MUMPS array of lines to parse into a specification + ; @param {array} METADATA - (passed by reference) the spec to be merged into ^VPRMETA(metatype) + ; @param {array} METACLTN - (passed by reference) the collection names to be merged into ^VPRMETA(collection) +BLDSPEC(METATYPE,LINES,METADATA,METACLTN) ; ; CLTNS(name)="" ;name of each collection ; FIELDS(0,seq#)=field ;general field descriptor ; FIELDS(ctn,seq#)=field ;override field descriptor for collection ; ATTR(name)=value ;value for attribute - ; MATCH(name)="" ;name used for matching in MATCH type index l + ; MATCH(name)="" ;name used for matching in MATCH type index ; K METADATA,METACLTN N I,X,SPECNAME,GROUP,LINE,CLTN,CLTNS,FIELD,FIELDS,ATTR,MATCH,STYLE,ERRORS @@ -95,7 +97,9 @@ M METADATA(SPECNAME)=SPEC I TYPE="data" S TYPE="src",OREF="^VPRJD(KEY," ; Add support for Generic Data Store (GDS) ; All Generic Data stores are listed in ^VPRCONFIG - I $G(HTTPREQ("store"))'="",$D(^VPRCONFIG("store",$G(HTTPREQ("store")))) S TYPE="src",OREF="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"(KEY," + I (TYPE'="src"),(TYPE'="tgt"),(TYPE'="vpr"),(TYPE'="data"),($G(HTTPREQ("store"))'="") D + . I $D(^VPRCONFIG("store",HTTPREQ("store"))) D + . . S TYPE="src",OREF="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"(KEY," ; S SPEC("merge")=0 S TMPLT=$P(FLD,";",2),FLD=$P(FLD,";") diff --git a/VPRJCD1.m b/VPRJCD1.m old mode 100755 new mode 100644 diff --git a/VPRJCF.m b/VPRJCF.m old mode 100755 new mode 100644 diff --git a/VPRJCO.m b/VPRJCO.m old mode 100755 new mode 100644 index 912f4fa..d9de198 --- a/VPRJCO.m +++ b/VPRJCO.m @@ -15,26 +15,36 @@ ; ORDER(#,"ftype")=1|2|3|4 ; field name structure ; ORDER(#,"field")=name ; field name ; ORDER(#,"mult")=name ; multiple name + ; ORDER(#,"nocase")=1 or 0 ; 1 = case insensitive, 0 = case sensitive ; ORDER(#,"sub")=name ; subfield name ; ORDER(#,"instance")=level ; which field to use for multiple instance ; - N I,X,F,D,S ; F=field, D=direction + N I,X,F,D,S,C ; F=field, D=direction, C=case sensitivity S S=0 ; S=number of sort levels S X=$$LOW^XLFSTR($$TRIM^XLFSTR(ORDER)) ; if only "asc" or "desc" passed - I X="asc"!(X="desc") S ORDER=$P($G(INDEX("order"))," ")_" "_X + ; if order field not passed in the order parameter in first sort level, use default order field from index + ; use of default order field from index only allowed for first sort level + I ",asc,desc,ci,cs,"[(","_$P(X," ")_",") S ORDER=$P($G(INDEX("order"))," ")_" "_X S X=$P(ORDER," ") - I X="asc"!(X="desc") D SETERROR^VPRJRER(110) Q ; missing order field + I ",asc,desc,ci,cs,"[(","_X_",") D SETERROR^VPRJRER(110) Q ; missing order field I '$L(ORDER) S ORDER=$G(INDEX("order")) ; use default if no ORDER parameter - I '$L(ORDER) S ORDER(0)=0 Q ; no sorting + I '$L(ORDER) S ORDER(0)=0 QUIT ; no sorting ; loop through the sorting levels (delimited by commas) + N J,OPT F I=1:1:$L(ORDER,",") S X=$$TRIM^XLFSTR($P(ORDER,",",I)) Q:'$L(X) D Q:$G(HTTPERR) . S S=S+1 . S F=$$TRIM^XLFSTR($P(X," ")) - . S D=$$LOW^XLFSTR($$TRIM^XLFSTR($P(X," ",2))) S:'$L(D) D="asc" + . S D="asc" + . S C="cs" + . F J=2:1:$L(X," ") D + . . S OPT=$$LOW^XLFSTR($$TRIM^XLFSTR($P(X," ",J))) + . . S:OPT="asc"!(OPT="desc") D=OPT + . . S:OPT="ci"!(OPT="cs") C=OPT . ; if sorting on something already in the index, use the index value . S ORDER(I)=$S($D(INDEX("alias",F)):INDEX("alias",F),1:F) . I +ORDER(I),$G(INDEX("collate",ORDER(I)))="V" S D=$S(D="asc":"desc",1:"asc") . S ORDER(I,"dir")=$S(D="desc":-1,1:1) + . S ORDER(I,"nocase")=$S(C="ci":1,1:0) . Q:+ORDER(I) . I F["[" D SETERROR^VPRJRER(109,F) Q ; arrays have to be indexed for sorting . N SPEC @@ -43,5 +53,5 @@ . Q:'$L(TEMPLATE) . ; TODO: iterate through template aliases and build a spec for each collection S ORDER(0)=S - Q + QUIT ; diff --git a/VPRJCONFIG.m b/VPRJCONFIG.m index 87f9584..3da572d 100644 --- a/VPRJCONFIG.m +++ b/VPRJCONFIG.m @@ -1,5 +1,4 @@ -VPRJCONFIG ;KRM/CJE -- Set up JDS configuration ; 4/25/17 4:01pm - ;;1.0;JSON DATA STORE;;Aug 5, 2015 +VPRJCONFIG ;KRM/CJE -- Set up JDS configuration ; SETUP ; ; Add default route/url map and default generic data stores @@ -28,20 +27,42 @@ S:'$G(^VPRCONFIG("timeout","pthash")) ^VPRCONFIG("timeout","pthash")=1 S:'$G(^VPRCONFIG("timeout","jpid")) ^VPRCONFIG("timeout","jpid")=30 ; + ; String size limit for POST query parameters + S:'$G(^VPRCONFIG("maxStringLimit")) ^VPRCONFIG("maxStringLimit")=3641000 ; Garbage Collector S:'$G(^VPRCONFIG("timeout","gc")) ^VPRCONFIG("timeout","gc")=30 ; Generic Data Store S:'$G(^VPRCONFIG("timeout","gds")) ^VPRCONFIG("timeout","gds")=30 ; + ; Whether or not we want to log socket errors to JDS's internal HTTP log + S:'$G(^VPRCONFIG("handleSocketError")) ^VPRCONFIG("handleSocketError")=0 + ; TCP socket buffer sizes - 1048576 is the default if /IBUFSIZ and /OBUFSIZ are not included in socket open command in VPRJREQ + S:'$G(^VPRCONFIG("HTTP","inputBuffer")) ^VPRCONFIG("HTTP","inputBuffer")=1048576 + S:'$G(^VPRCONFIG("HTTP","outputBuffer")) ^VPRCONFIG("HTTP","outputBuffer")=1048576 + ; Whether or not we want to wrap the re-index utilities with a lock and a transaction + S:'$G(^VPRCONFIG("reindexLockTransactions")) ^VPRCONFIG("reindexLockTransactions")=0 + ; Set VVMAX Values + S:'$G(^VPRCONFIG("vvmax","decoder")) ^VPRCONFIG("vvmax","decoder")=100 + S:'$G(^VPRCONFIG("vvmax","encoder")) ^VPRCONFIG("vvmax","encoder")=100 ; Add default generic data stores F SEQ=1:1 S STORE=$P($T(DEFAULTSTORE+SEQ),";;",2) Q:STORE="zzzzz" D . D ADDSTORE($P(STORE,";",1),$P(STORE,";",2)) - N SEQ + K SEQ ; Add default route/url map F SEQ=1:1 S URLMAP=$P($T(URLMAP+SEQ),";;",2) Q:URLMAP="zzzzz" D . D ADDURL($P(URLMAP,";",1),$P(URLMAP,";",2),$P(URLMAP,";",3)) + ; + ; Cleanup old store-index urls + K SEQ,STORE + S STORE="" + S SEQ="" + F S STORE=$O(^VPRCONFIG("urlmap","store-index",STORE)) Q:STORE="" D + . F S SEQ=$O(^VPRCONFIG("urlmap","store-index",STORE,SEQ)) Q:SEQ="" D + . . I '$D(^VPRCONFIG("urlmap",SEQ)) D + . . . W "Deleting unused entry: ^VPRCONFIG(""urlmap"",""store-index"","_STORE_","_SEQ_")",! + . . . K ^VPRCONFIG("urlmap","store-index",STORE,SEQ) Q -CREATEDB(ARGS,BODY) +CREATEDB(ARGS,BODY) ; Wrapper for ADDSTORE to be a REST endpoint ; ; Arguments: @@ -56,7 +77,7 @@ D ADDSTORE(ARGS("store")) ; this should return {"ok":true} ; current HTTP responder can't handle this on a POST Q "/"_ARGS("store") -ADDSTORE(DB,GLOBAL,VER) +ADDSTORE(DB,GLOBAL,VER,ARGS) ; Parameters: ; ; DB = database name @@ -75,20 +96,29 @@ D ADDSTORE(ARGS("store")) I $L(DB)=0!($L(DB)>10)!(DB'?1.10AN) D SETERROR^VPRJRER(252) Q S DB=$$LOW^VPRJRUT(DB) S UDB=$$UP^VPRJRUT(DB) + I $D(ARGS) D DECODE^VPRJSON("ARGS","OBJECT","ERR") + I $D(ERR) D SETERROR^VPRJRER(202) QUIT "" S VER=$G(VER,1) ; Default version to 1 unless specified - ; ensure DB isn't created - I $D(^VPRCONFIG("store",DB)) D SETERROR^VPRJRER(254) Q + ; S ^VPRCONFIG("store",DB)="" S ^VPRCONFIG("store",DB,"global")=$S($L($G(GLOBAL))>1:GLOBAL,1:"VPRJ"_UDB) S ^VPRCONFIG("store",DB,"version")=VER - ; CRUD Operations + S ^VPRCONFIG("store",DB,"lockTimeout")=$G(OBJECT("lockTimeout"),300) + ; Add GDS Operations + ; order from most specific to least specific for routes to apply as expected + D ADDURL("GET",DB_"/index/{indexName}","INDEX^VPRJGDS",DB) ; Retrieve using index + D ADDURL("GET",DB_"/index/{indexName}/{template}","INDEX^VPRJGDS",DB) ; Retrieve using index and template + D ADDURL("POST",DB_"/index","CINDEX^VPRJGDS",DB) ; Create Index + D ADDURL("POST",DB_"/template","CTEMPLATE^VPRJGDS",DB) ; Create Template + D ADDURL("GET",DB_"/lock","GETLOCK^VPRJGDS",DB) ; Get lock table + D ADDURL("GET",DB_"/lock/{uid}","GETLOCK^VPRJGDS",DB) ; Get lock table for a uid + D ADDURL("PUT",DB_"/lock/{uid}","SETLOCK^VPRJGDS",DB) ; Acquire a lock on a uid + D ADDURL("DELETE",DB_"/lock/{uid}","DELLOCK^VPRJGDS",DB) ; Remove a lock on a uid D ADDURL("GET",DB_"/{uid}","GET^VPRJGDS",DB) ; Return given document + D ADDURL("GET",DB_"/{uid}/{template}","GET^VPRJGDS",DB) ; Return given document using template D ADDURL("PUT",DB_"/{uid}","SET^VPRJGDS",DB) ; Set given document - UID provided D ADDURL("PATCH",DB_"/{uid}","SET^VPRJGDS",DB) ; update a given document - UID provided D ADDURL("DELETE",DB_"/{uid}","DEL^VPRJGDS",DB) ; Delete given document - ; Index Operations - D ADDURL("GET",DB_"/index/{indexName}","INDEX^VPRJGDS",DB) ; Retrieve using index - D ADDURL("POST",DB_"/index","CINDEX^VPRJGDS",DB) ; Create Index ; DB Operations ; ; PUT creates new database - not store specific @@ -98,20 +128,24 @@ D ADDSTORE(ARGS("store")) D ADDURL("POST",DB,"SET^VPRJGDS",DB) ; Set new document - no UID D ADDURL("DELETE",DB,"CLR^VPRJGDS",DB) ; remove the db Q -ADDURL(METHOD,URL,ROUTINE,STORE) +ADDURL(METHOD,URL,ROUTINE,STORE) ; Parameters: ; ; METHOD = HTTP method (POST,PUT,DELETE,GET) ; URL = The URL Pattern to match ; ROUTINE = TAG^ROUTINE to execute to handle the URL ; STORE = Store name for deletion index - N SEQ,URLMAPNUM,DONE + N SEQ,URLMAPNUM ; Ensure url config doesn't exist S URLMAPNUM="" - S DONE=0 - F S URLMAPNUM=$O(^VPRCONFIG("urlmap","url-index",URL,URLMAPNUM)) Q:URLMAPNUM="" D Q:DONE - . I URL=$G(^VPRCONFIG("urlmap",URLMAPNUM,"url"))&(METHOD=$G(^VPRCONFIG("urlmap",URLMAPNUM,"method"))) S DONE=1 - I DONE Q + F S URLMAPNUM=$O(^VPRCONFIG("urlmap","url-index",URL,URLMAPNUM)) Q:URLMAPNUM="" D + . I URL=$G(^VPRCONFIG("urlmap",URLMAPNUM,"url"))&(METHOD=$G(^VPRCONFIG("urlmap",URLMAPNUM,"method"))) D + . . ; Remove the URL from the urlmap + . . K:$D(^VPRCONFIG("urlmap",URLMAPNUM)) ^VPRCONFIG("urlmap",URLMAPNUM) + . . ; Remove the URL from the url-index + . . K:$D(^VPRCONFIG("urlmap","url-index",URL,URLMAPNUM)) ^VPRCONFIG("urlmap","url-index",URL,URLMAPNUM) + . . ; Remove the URL in store-index + . . I $G(STORE) K:$D(^VPRCONFIG("urlmap","store-index",STORE,URLMAPNUM)) ^VPRCONFIG("urlmap","store-index",STORE,URLMAPNUM) S SEQ=$I(^VPRCONFIG("urlmap")) S ^VPRCONFIG("urlmap",SEQ,"method")=$G(METHOD) S ^VPRCONFIG("urlmap",SEQ,"url")=$G(URL) @@ -123,21 +157,7 @@ D ADDSTORE(ARGS("store")) ; Index for each url S ^VPRCONFIG("urlmap","url-index",URL,SEQ)="" Q -DEFAULTSTORE ; - ;;ehmpusers - ;;entordrbls - ;;permission - ;;permset - ;;teamlist - ;;trustsys - ;;pidmeta - ;;commreq - ;;clinicobj - ;;ordersets - ;;quickorder - ;;orderfavs - ;;entordrbls - ;;activeusr +DEFAULTSTORE ;;zzzzz Q URLMAP ; map URLs to entry points (HTTP methods handled within entry point) @@ -226,7 +246,7 @@ D ADDSTORE(ARGS("store")) ;;POST;status/{id};SET^VPRJPSTATUS ;;DELETE;status;CLEAR^VPRJPSTATUS ;;DELETE;status/{pid};CLEAR^VPRJPSTATUS - ;;POST;record;STORERECORD^VPRJPSTATUS + ;;POST;status/{pid}/store;STORERECORD^VPRJPSTATUS ;;GET;statusod/{id};GET^VPRJDSTATUS ;;PUT;statusod/{id};SET^VPRJDSTATUS ;;POST;statusod/{id};SET^VPRJDSTATUS @@ -260,15 +280,6 @@ D ADDSTORE(ARGS("store")) ;;GET;tasks/gc/data;DATA^VPRJGC ;;GET;tasks/gc/job/{id};JOB^VPRJGC ;;GET;tasks/gc/job;JOB^VPRJGC - ;;POST;error/set/this;SET^VPRJERR - ;;PUT;error/set/this;SET^VPRJERR - ;;GET;error/get/{id};GET^VPRJERR - ;;GET;error/get;GET^VPRJERR - ;;GET;error/length/this;LEN^VPRJERR - ;;DELETE;error/destroy/{id};DEL^VPRJERR - ;;GET;error/destroy/{id};DEL^VPRJERR - ;;DELETE;error/clear/this;CLR^VPRJERR - ;;GET;error/clear/this;CLR^VPRJERR ;;PUT;{store};CREATEDB^VPRJCONFIG ;;GET;documentation;DATA^VPRJDOCS ;;GET;documentation/index;INDEX^VPRJDOCS diff --git a/VPRJCONV.m b/VPRJCONV.m index aef3b7d..6d9d2a7 100644 --- a/VPRJCONV.m +++ b/VPRJCONV.m @@ -1,11 +1,14 @@ -VPRJCONV ;V4W/DLW,KRM/CJE -- Conversion routine to convert the old sync status metastamp to the new one - ;;1.0;JSON DATA STORE;;Nov 04, 2015 +VPRJCONV ;V4W/DLW,KRM/CJE -- Conversion routine to make conversions to JDS data that has changed ; QUIT ; Should not be called from the top ; ; This routine should be run at every site that was running JDS before the conversion to the new metastamp + ; This routine makes extensive use of ^TMP. This is used as a temprory work place for conversions to happen + ; If this process needs to be re-ran (due to a crash, etc). The data stored in ^TMP is important to keep around. + ; This cannot be moved to process private globals. ; SYNCSTS ; Entry point for sync status metastamp conversion + ; Convert the old sync status metastamp to the new one N STARTOD,STARTPAT,ENDTIME,TOTALTIME,ODTIME,ODAVG,PATTIME,PATAVG,I,J,PID,SITE,SOURCESTAMP,DOMAIN ; I $D(^VPRJSAVD) W "^VPRJSAVD is not empty, aborting!",! QUIT @@ -38,18 +41,18 @@ . ; . F S DOMAIN=$O(^VPRSTATUSOD(SITE,SOURCESTAMP,DOMAIN)) Q:DOMAIN="" D . . ; Delete the domain stored node - . . K ^VPRSTATUSOD(SITE,SOURCESTAMP,DOMAIN,SOURCESTAMP,"stored") + . . K:$D(^VPRSTATUSOD(SITE,SOURCESTAMP,DOMAIN,SOURCESTAMP,"stored")) ^VPRSTATUSOD(SITE,SOURCESTAMP,DOMAIN,SOURCESTAMP,"stored") . ; - . ZK ^VPRSTATUSOD(SITE,SOURCESTAMP) ; Delete the data, but not the descendants + . ZK:$D(^VPRSTATUSOD(SITE,SOURCESTAMP))#10 ^VPRSTATUSOD(SITE,SOURCESTAMP) ; Delete the data, but not the descendants . ; Save off newest metastamp to a temp global . M ^VPRJSTMP("VPRSTATUSOD",SITE)=^VPRSTATUSOD(SITE,SOURCESTAMP) . S ^VPRJSTMP("VPRSTATUSOD",SITE,"stampTime")=SOURCESTAMP - . K ^VPRSTATUSOD(SITE) + . K:$D(^VPRSTATUSOD(SITE)) ^VPRSTATUSOD(SITE) . M ^VPRSTATUSOD(SITE)=^VPRJSTMP("VPRSTATUSOD",SITE) . ; . TC ; - K ^VPRJSTMP("VPRSTATUSOD") + K:$D(^VPRJSTMP("VPRSTATUSOD")) ^VPRJSTMP("VPRSTATUSOD") ; L -^VPRSTATUSOD ; @@ -77,18 +80,18 @@ . ; . F S DOMAIN=$O(^VPRSTATUS(PID,SITE,SOURCESTAMP,DOMAIN)) Q:DOMAIN="" D . . ; Delete the domain stored node - . . K ^VPRSTATUS(PID,SITE,SOURCESTAMP,DOMAIN,SOURCESTAMP,"stored") + . . K:$D(^VPRSTATUS(PID,SITE,SOURCESTAMP,DOMAIN,SOURCESTAMP,"stored")) ^VPRSTATUS(PID,SITE,SOURCESTAMP,DOMAIN,SOURCESTAMP,"stored") . ; - . ZK ^VPRSTATUS(PID,SITE,SOURCESTAMP) ; Delete the data, but not the descendants + . ZK:$D(^VPRSTATUS(PID,SITE,SOURCESTAMP))#10 ^VPRSTATUS(PID,SITE,SOURCESTAMP) ; Delete the data, but not the descendants . ; Save off newest metastamp to a temp global . M ^VPRJSTMP("VPRSTATUS",PID,SITE)=^VPRSTATUS(PID,SITE,SOURCESTAMP) . S ^VPRJSTMP("VPRSTATUS",PID,SITE,"stampTime")=SOURCESTAMP - . K ^VPRSTATUS(PID,SITE) + . K:$D(^VPRSTATUS(PID,SITE)) ^VPRSTATUS(PID,SITE) . M ^VPRSTATUS(PID,SITE)=^VPRJSTMP("VPRSTATUS",PID,SITE) . ; . TC ; - K ^VPRJSTMP("VPRSTATUS") + K:$D(^VPRJSTMP("VPRSTATUS")) ^VPRJSTMP("VPRSTATUS") ; L -^VPRSTATUS ; @@ -181,13 +184,13 @@ D DISPTIME(PATTIME,"Total time for patient data:") . ; Save to cache mode, back up the original node to a memory-backed global . E I SAVE=2 M ^TMP("VPRJSAVA",PID)=^VPRPT(PID) . ; Kill original patient array node - . K ^VPRPT(PID) + . K:$D(^VPRPT(PID)) ^VPRPT(PID) . ; . TC ; Merge all patients back in to ^VPRPT W "Merging ^TMP(""VPRJSVPT"",""ARRAY"") back in to ^VPRPT",! M ^VPRPT=^TMP("VPRJSVPT","ARRAY") - K ^TMP("VPRJSVPT","ARRAY") + K:$D(^TMP("VPRJSVPT","ARRAY")) ^TMP("VPRJSVPT","ARRAY") W "Merged ^TMP(""VPRJSVPT"",""ARRAY"") back in to ^VPRPT",! ; L -^VPRPT @@ -223,13 +226,13 @@ D DISPTIME(PATTIME,"Total time for patient data:") . ; Save to cache mode, back up the original node to a memory-backed global . E I SAVE=2 M ^TMP("VPRJSAVJ",PID)=^VPRPTJ("JSON",PID) . ; Kill original patient JSON node - . K ^VPRPTJ("JSON",PID) + . K:$D(^VPRPTJ("JSON",PID)) ^VPRPTJ("JSON",PID) . ; . TC ; Merge all patients back in to ^VPRPTJ("JSON") W "Merging ^TMP(""VPRJSVPT"",""JSON"") back in to ^VPRPTJ(""JSON"")",! M ^VPRPTJ("JSON")=^TMP("VPRJSVPT","JSON") - K ^TMP("VPRJSVPT","JSON") + K:$D(^TMP("VPRJSVPT","JSON")) ^TMP("VPRJSVPT","JSON") W "Merged ^TMP(""VPRJSVPT"",""JSON"") back in to ^VPRPTJ(""JSON"")",! ; L -^VPRPTJ("JSON") @@ -265,13 +268,13 @@ D DISPTIME(PATTIME,"Total time for patient data:") . ; Save to cache mode, back up the original node to a memory-backed global . E I SAVE=2 M ^TMP("VPRJSAVI",PID)=^VPRPTI(PID) . ; Kill original patient index node - . K ^VPRPTI(PID) + . K:$D(^VPRPTI(PID)) ^VPRPTI(PID) . ; . TC ; Merge all patients back in to ^VPRPTI W "Merging ^TMP(""VPRJSVPT"",""INDEX"") back in to ^VPRPTI",! M ^VPRPTI=^TMP("VPRJSVPT","INDEX") - K ^TMP("VPRJSVPT","INDEX") + K:$D(^TMP("VPRJSVPT","INDEX")) ^TMP("VPRJSVPT","INDEX") W "Merged ^TMP(""VPRJSVPT"",""INDEX"") back in to ^VPRPTI",! ; L -^VPRPTI @@ -309,13 +312,13 @@ D DISPTIME(PATTIME,"Total time for patient data:") . ; Save to cache mode, back up the original node to a memory-backed global . E I SAVE=2 M ^TMP("VPRJSAVT",PID)=^VPRPTJ("TEMPLATE",PID) . ; Kill original patient template node - . K ^VPRPTJ("TEMPLATE",PID) + . K:$D(^VPRPTJ("TEMPLATE",PID)) ^VPRPTJ("TEMPLATE",PID) . ; . TC ; Merge all patients back in to ^VPRPTJ("TEMPLATE") W "Merging ^TMP(""VPRJSVPT"",""TEMPLATE"") back in to ^VPRPTJ(""TEMPLATE"")",! M ^VPRPTJ("TEMPLATE")=^TMP("VPRJSVPT","TEMPLATE") - K ^TMP("VPRJSVPT","TEMPLATE") + K:$D(^TMP("VPRJSVPT","TEMPLATE")) ^TMP("VPRJSVPT","TEMPLATE") W "Merged ^TMP(""VPRJSVPT"",""TEMPLATE"") back in to ^VPRPTJ(""TEMPLATE"")",! ; L -^VPRPTJ("TEMPLATE") @@ -351,13 +354,13 @@ D DISPTIME(PATTIME,"Total time for patient data:") . ; Save to cache mode, back up the original node to a memory-backed global . E I SAVE=2 M ^TMP("VPRJSAVS",PID)=^VPRSTATUS(PID) . ; Kill original patient sync status node - . K ^VPRSTATUS(PID) + . K:$D(^VPRSTATUS(PID)) ^VPRSTATUS(PID) . ; . TC ; Merge all patients back in to ^VPRSTATUS W "Merging ^TMP(""VPRJSVPT"",""STATUS"") back in to ^VPRSTATUS",! M ^VPRSTATUS=^TMP("VPRJSVPT","STATUS") - K ^TMP("VPRJSVPT","STATUS") + K:$D(^TMP("VPRJSVPT","STATUS")) ^TMP("VPRJSVPT","STATUS") W "Merged ^TMP(""VPRJSVPT"",""STATUS"") back in to ^VPRSTATUS",! ; L -^VPRSTATUS @@ -464,3 +467,18 @@ D DISPTIME(STSTIME,"Total time for patient sync status data:") W !,?$L(MSG),"("_TIME_" Total Seconds)",! ; QUIT + ; +DELERROR ; Delete the old JDS error store data and URL mappings + N URL,NUM + ; + F URL="error/set/this","error/get/{id}","error/get","error/length/this","error/destroy/{id}","error/clear/this" D + . S NUM=0 + . F S NUM=$O(^VPRCONFIG("urlmap","url-index",URL,NUM)) Q:NUM="" D + . . K:$D(^VPRCONFIG("urlmap",NUM)) ^VPRCONFIG("urlmap",NUM) + . K:$D(^VPRCONFIG("urlmap","url-index",URL)) ^VPRCONFIG("urlmap","url-index",URL) + K:$D(^VPRJERR) ^VPRJERR + ; + I ($D(^VPRJERR))!($O(^VPRCONFIG("urlmap","url-index","err"))["error") W "Old JDS error store was not completely deleted..",! + E W "Old JDS error store is successfully deleted..",! + ; + QUIT diff --git a/VPRJCR.m b/VPRJCR.m old mode 100755 new mode 100644 diff --git a/VPRJCRC.m b/VPRJCRC.m old mode 100755 new mode 100644 diff --git a/VPRJCT.m b/VPRJCT.m old mode 100755 new mode 100644 index d03b7d5..60ea3c4 --- a/VPRJCT.m +++ b/VPRJCT.m @@ -212,5 +212,5 @@ F S I(N)=$O(@SPEC(LEVEL,"srcArrays",N,"ref"),SPEC(LEVEL,"srcArrays",N,"dir")) Q DELVAL ; delete value if last position, otherwise recurse to next I N: Error code followed by UUID key to retrieveQueryResult in pjds-client.js +GETOBJ(IDENTIFIER,TEMPLATE,START,LIMIT,STARTID,RETCNTS) ; Called as getOperationalDataByUid in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("uid")=$G(IDENTIFIER) + S ARGS("template")=$G(TEMPLATE) + S HTTPREQ("store")="data" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no uid passed in + I $G(IDENTIFIER)="" D SETERROR^VPRJRER(104) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D GETOBJ^VPRJDR(.RESULT,.ARGS) + ; ods code will return a result pointer even if empty, which breaks $$RETURNDATA^VPRJUTLN, so handle that + K:'$D(@RESULT) RESULT + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; GET for objects by index + ; + ; @param {string} INDEX - The index to use to retrieve the data + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [RANGE=""] - A range of keys to limit the items being retrieved by index + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in pjds-client.js +INDEX(INDEX,TEMPLATE,ORDER,RANGE,BAIL,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getOperationalIndexData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("indexName")=$G(INDEX) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("range")=$G(RANGE) + S ARGS("bail")=$G(BAIL) + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")="data" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no index name passed in + I $G(INDEX)="" D SETERROR^VPRJRER(101) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D INDEX^VPRJDR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get tally or count of objects + ; + ; @param {string} COUNTNAME - The name of the tally or count to retrieve + ; @param {string} [ALL=""] - If passed with value of "true," receive COUNT instead of TALLY + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in pjds-client.js +COUNT(COUNTNAME,ALL,START,LIMIT,STARTID,RETCNTS) ; Called as getOperationalDataCount in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("countName")=$G(COUNTNAME) + S HTTPREQ("store")="data" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no count name passed in + I $G(COUNTNAME)="" D SETERROR^VPRJRER(101) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint (if ALL=true, use ALLCOUNT endpoint, otherwise default to COUNT + I $G(ALL)="true" D ALLCOUNT^VPRJDR(.RESULT,.ARGS) + E D COUNT^VPRJDR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get objects by collection + ; + ; @param {string} COLLECTION - The collection of objects to retrieve + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in pjds-client.js +FIND(COLLECTION,TEMPLATE,ORDER,BAIL,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getOperationalDataCollection in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("collection")=$G(COLLECTION) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("bail")=$G(BAIL) + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")="data" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no uid passed in + I $G(COLLECTION)="" D SETERROR^VPRJRER(215) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D FIND^VPRJDR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; diff --git a/VPRJDS.m b/VPRJDS.m old mode 100755 new mode 100644 index 5fc9311..c63c492 --- a/VPRJDS.m +++ b/VPRJDS.m @@ -24,8 +24,12 @@ I OLDSTAMP'="",STAMP'TIMEOUT) K @GLOBALL@(ARGS("uid")) + . ; Always return the requested UID + . I $L(TEMPLATE) M RESULT=@GLOBALJ@("TEMPLATE",ARGS("uid"),TEMPLATE) + . E M RESULT=@GLOBALJ@("JSON",ARGS("uid")) + . L -@GLOBALL@(ARGS("uid")) . L -@GLOBAL@(ARGS("uid")) - I $D(ERR) D SETERROR^VPRJRER(229,"uid "_ARGS("uid")_" doesn't exist") Q + . ; + . I '$D(RESULT) D SETERROR^VPRJRER(229,"uid "_ARGS("uid")_" doesn't exist") Q + I $G(ARGS("startid"))'="" S STARTID=$O(@GLOBAL@(ARGS("startid")),-1),STARTID=$O(@GLOBAL@(STARTID)) + ; ; Get all objects (or run filter) if no uid passed - I '$D(@OBJECT) D - . N UID - . S UID=0 - . N I - . F I=1:1 S UID=$O(@GLOBAL@(UID)) Q:UID="" D - . . ; All clauses are wrapped in an implicit AND - . . I $D(CLAUSES) Q:'$$EVALAND^VPRJGQF(.CLAUSES,$NA(@GLOBAL@(UID))) - . . ; Merge the data (will run only if the filter is true or non-existant) - . . L +@GLOBAL@(UID):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q - . . M @OBJECT@("items",I)=@GLOBAL@(UID) - . . L -@GLOBAL@(UID) - I $G(HTTPERR) QUIT - ; Set Result variable to global - S RESULT=$NA(^TMP($J,"RESULT")) - K @RESULT - ; Encode object into JSON return - D ENCODE^VPRJSON(OBJECT,RESULT,"ERR") ; From an array to JSON - ; Clean up staging variable - K @OBJECT - I $D(ERR) D SETERROR^VPRJRER(202) Q - Q + S UID=0 + F S UID=$O(@GLOBAL@(UID)) Q:UID="" D ADDONE^VPRJGDSQA(UID,0,,SKIPLOCK) + D BUILD^VPRJCB + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) + S RESULT=$NA(^||TMP($J)),RESULT("pageable")="gds",RESULT("startid")=$G(STARTID) + QUIT ; CINDEX(ARGS,BODY) N OBJECT,ERR,RESULT,GLOBAL,GLOBALJ,UID,INCR,OLDOBJ,LINES,METADATA,METACLTN,METATYPE ; Ensure the store is setup and correct - I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) Q "" + I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) QUIT "" S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) S GLOBALJ="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"J" I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) Q "" ; ; If the body is null just return with error - I '$D(BODY) D SETERROR^VPRJRER(255) Q "" + I '$D(BODY) D SETERROR^VPRJRER(255) QUIT "" ; D DECODE^VPRJSON("BODY","OBJECT","ERR") ; From JSON to an array - I $D(ERR) D SETERROR^VPRJRER(202) Q "" + I $D(ERR) D SETERROR^VPRJRER(202) QUIT "" ; ; Ensure all data fields exist - I $G(OBJECT("indexName"))=""!($G(OBJECT("fields"))="")!($G(OBJECT("sort"))="")!($G(OBJECT("type"))="") D SETERROR^VPRJRER(273,"required field missing") Q "" + I $G(OBJECT("indexName"))=""!($G(OBJECT("fields"))="")!($G(OBJECT("sort"))="")!($G(OBJECT("type"))="") D SETERROR^VPRJRER(273,"required field missing") QUIT "" ; ; If the index already exists stop processing and tell the user - I $D(^VPRMETA("index",$G(OBJECT("indexName")))) D SETERROR^VPRJRER(271,"index name: "_$G(OBJECT("indexName"))) Q "" - I $D(^VPRMETA("collection",HTTPREQ("store"),"index",$G(OBJECT("indexName")))) D SETERROR^VPRJRER(271,"index name: "_$G(OBJECT("indexName"))) Q "" + I $D(^VPRMETA("index",$G(OBJECT("indexName")))) D SETERROR^VPRJRER(271,"index name: "_$G(OBJECT("indexName"))) QUIT "" + I $D(^VPRMETA("collection",HTTPREQ("store"),"index",$G(OBJECT("indexName")))) D SETERROR^VPRJRER(271,"index name: "_$G(OBJECT("indexName"))) QUIT "" ; ; Parse the JSON into format BLDSPEC needs S LINES(1)=$G(OBJECT("indexName")) S LINES(2)="collections: "_$G(HTTPREQ("store")) S LINES(3)="fields: "_$G(OBJECT("fields")) S LINES(4)="sort: "_$G(OBJECT("sort")) + S LINES(5)="setif: "_$G(OBJECT("setif")) ; S METATYPE="index:"_$S($G(OBJECT("type"))="attr":"attr",1:"tally") D BLDSPEC^VPRJCD(METATYPE,.LINES,.METADATA,.METACLTN) ; build it K LINES ; The lines are no longer necessary - I $D(METADATA("errors","errors")) D SETERROR^VPRJRER(270) Q "" + I $D(METADATA("errors","errors")) D SETERROR^VPRJRER(270) QUIT "" M ^VPRMETA($P(METATYPE,":"))=METADATA ; save it M ^VPRCONFIG("store",$G(HTTPREQ("store")),"index",$G(OBJECT("indexName")))=METADATA M ^VPRMETA("collection")=METACLTN ; map collections to it @@ -255,28 +301,191 @@ S LINES(4)="sort: "_$G(OBJECT("sort")) . D ENCODE^VPRJSON("OBJECT","DOCUMENT","ERR") . I $D(ERR) D SETERROR^VPRJRER(202) Q . ; Merge Raw JSON - . K @GLOBALJ@("JSON",UID) + . K:$D(@GLOBALJ@("JSON",UID)) @GLOBALJ@("JSON",UID) . M @GLOBALJ@("JSON",UID)=DOCUMENT - Q "" + QUIT "" ; INDEX(RESULT,ARGS) ; GET objects by index - I $$UNKARGS^VPRJCU(.ARGS,"indexName,range,order,bail,filter,start") Q + I $$UNKARGS^VPRJCU(.ARGS,"indexName,range,order,bail,filter,start,template,startid,returncounts,skiplocked") QUIT ; Ensure the store is setup and correct - I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) Q "" + I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) QUIT "" N GLOBAL S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) - I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) Q "" + I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) QUIT "" ; - N INDEX,RANGE,ORDER,BAIL,FILTER + N INDEX,RANGE,ORDER,BAIL,FILTER,STARTID,SKIPLOCK S INDEX=$G(ARGS("indexName")) S RANGE=$G(ARGS("range")) S ORDER=$G(ARGS("order")) S BAIL=$G(ARGS("bail")) S FILTER=$G(ARGS("filter")) - I $G(INDEX)="" D SETERROR^VPRJRER(102,INDEX) Q - I '$D(^VPRMETA("index",INDEX)) D SETERROR^VPRJRER(102,INDEX) Q + S TEMPLATE=$G(ARGS("template")) + S SKIPLOCK=$S($G(ARGS("skiplocked"))="true":1,1:0) + I $G(INDEX)="" D SETERROR^VPRJRER(102,INDEX) QUIT + I '$D(^VPRMETA("index",INDEX)) D SETERROR^VPRJRER(102,INDEX) QUIT ; ; Do the query - D QINDEX^VPRJGDSQ(INDEX,RANGE,ORDER,BAIL,"",FILTER) - S RESULT=$NA(^TMP($J)),RESULT("pageable")="" - Q + D QINDEX^VPRJGDSQ(INDEX,RANGE,ORDER,BAIL,TEMPLATE,FILTER,SKIPLOCK) + I $G(ARGS("startid"))'="" S STARTID=$O(@GLOBAL@(ARGS("startid")),-1),STARTID=$O(@GLOBAL@(STARTID)) + S RESULT=$NA(^||TMP($J)),RESULT("pageable")="gds",RESULT("startid")=$G(STARTID) + QUIT + ; + ; Create a template definition for a generic data store + ; @param {array} ARGS - (passed by reference) HTTP query parameters/url parameters + ; @param {array} BODY - (passed by reference) HTTP content body in stringified JSON +CTEMPLATE(ARGS,BODY) + N OBJECT,ERR,RESULT,GLOBAL,GLOBALJ,UID,INCR,OLDOBJ,LINES,METATYPE,METADATA,METATYPE + ; Ensure the store is setup and correct + I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) QUIT "" + S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) + S GLOBALJ="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"J" + I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) QUIT "" + ; + ; If the body is null just return with error + I '$D(BODY) D SETERROR^VPRJRER(255) QUIT "" + ; + D DECODE^VPRJSON("BODY","OBJECT","ERR") ; From JSON to an array + I $D(ERR) D SETERROR^VPRJRER(202) QUIT "" + ; + ; Ensure all data fields exist + I $G(OBJECT("name"))=""!($G(OBJECT("directives"))="")!($G(OBJECT("fields"))="") D SETERROR^VPRJRER(273,"required field missing") QUIT "" + ; + ; If the index already exists stop processing and tell the user + I $D(^VPRMETA("template",$G(OBJECT("name")))) D SETERROR^VPRJRER(271,"template name: "_$G(OBJECT("name"))) QUIT "" + I $D(^VPRMETA("collection",HTTPREQ("store"),"template",$G(OBJECT("name")))) D SETERROR^VPRJRER(271,"template name: "_$G(OBJECT("name"))) QUIT "" + ; + ; Parse the JSON into format LOADSPEC needs + S LINES(1)=$G(OBJECT("name")) + S LINES(2)="collections: "_$G(HTTPREQ("store")) + S LINES(3)="directives: "_$G(OBJECT("directives")) + S LINES(4)="fields: "_$G(OBJECT("fields")) + ; + ; Build the SPEC + S METATYPE="template" + D BLDSPEC^VPRJCD(METATYPE,.LINES,.METADATA,.METACLTN) + ; + ; We no longer need the lines variable + K LINES + ; + ; report any errors from BLDSPEC back to the user and stop processing + I $D(METADATA("errors","errors")) D SETERROR^VPRJRER(270) QUIT "" + ; + ; Save the METADATA to ^VPRMETA and ^VPRCONFIG (for when ^VPRMETA is blown away) + M ^VPRMETA($P(METATYPE,":"))=METADATA + M ^VPRCONFIG("store",$G(HTTPREQ("store")),"template",$G(OBJECT("name")))=METADATA + ; + ; tell the collection it has a template + M ^VPRMETA("collection")=METACLTN + ; + ; Apply the template to existing data + S UID="" + F S UID=$O(@GLOBAL@(UID)) Q:UID="" Q:$D(ERR) D + . N OBJECT,DOCUMENT + . M OBJECT=@GLOBAL@(UID) + . D BLDTLT^VPRJCT1(HTTPREQ("store"),.OBJECT,.TLTARY) + . ; Merge templated object + . K:$D(@GLOBALJ@("TEMPLATE",UID)) @GLOBALJ@("TEMPLATE",UID) + . M @GLOBALJ@("TEMPLATE",UID)=TLTARY + QUIT "" + ; +GETLOCK(RESULT,ARGS) + N GLOBAL,GLOBALL,FILTER,CLAUSES,OBJECT,ERR,FMNOW,TIMEOUT,FMLOCK,FMTIMEOUT + ; Ensure the store is setup and correct + I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) QUIT + S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) + S GLOBALL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"L" + I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) QUIT + ; Get any filters and parse them into CLAUSES + S FILTER=$G(ARGS("filter")) + I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) QUIT:$G(HTTPERR) + ; Set OBJECT into ^||TMP($J) + S OBJECT=$NA(^||TMP($J,"OBJECT")) + ; Ensure variables are cleaned out + K:$D(@OBJECT) @OBJECT + ; Get single object + I $G(ARGS("uid"))'="" D + . L +@GLOBALL@(ARGS("uid")):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502,"unable to get locktable lock") Q + . ; Calculate the expiration time + . S FMNOW=$$HL7TFM^XLFDT($$CURRTIME^VPRJRUT) + . S TIMEOUT=$G(^VPRCONFIG("store",HTTPREQ("store"),"lockTimeout")) + . S FMLOCK=$$HL7TFM^XLFDT($G(@GLOBALL@(ARGS("uid")))) + . S FMTIMEOUT=$$FMADD^XLFDT(FMLOCK,,,,TIMEOUT) + . ; If the lock is expired delete it and don't return it + . I $$FMDIFF^XLFDT(FMNOW,FMTIMEOUT,2)>TIMEOUT K:$D(@GLOBALL@(ARGS("uid"))) @GLOBALL@(ARGS("uid")) + . ; The lock is not expired return it + . I $$FMDIFF^XLFDT(FMNOW,FMTIMEOUT,2)'>TIMEOUT M @OBJECT@(ARGS("uid"))=@GLOBALL@(ARGS("uid")) + . I '$D(@OBJECT) S ERR=1 + . L -@GLOBALL@(ARGS("uid")) + I $D(ERR) D SETERROR^VPRJRER(229,"uid "_ARGS("uid")_" doesn't exist") QUIT + I $G(HTTPERR) QUIT + ; Get all objects (or run filter) if no uid passed + I '$D(@OBJECT) D + . N UID + . S UID=0 + . N I + . F I=1:1 S UID=$O(@GLOBALL@(UID)) Q:UID="" D + . . ; All clauses are wrapped in an implicit AND + . . I $D(CLAUSES) Q:'$$EVALAND^VPRJGQF(.CLAUSES,$NA(@GLOBAL@(UID))) + . . ; Merge the data (will run only if the filter is true or non-existent) + . . L +@GLOBALL@(UID):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q + . . ; Calculate the expiration time + . . S FMNOW=$$HL7TFM^XLFDT($$CURRTIME^VPRJRUT) + . . S TIMEOUT=$G(^VPRCONFIG("store",HTTPREQ("store"),"lockTimeout")) + . . S FMLOCK=$$HL7TFM^XLFDT($G(@GLOBALL@(UID))) + . . S FMTIMEOUT=$$FMADD^XLFDT(FMLOCK,,,,TIMEOUT) + . . ; If the lock is expired delete it and don't return it + . . I $$FMDIFF^XLFDT(FMNOW,FMTIMEOUT,2)>TIMEOUT K:$D(@GLOBALL@(UID)) @GLOBALL@(UID) + . . ; The lock is not expired retun it + . . I $$FMDIFF^XLFDT(FMNOW,FMTIMEOUT,2)'>TIMEOUT M @OBJECT@("items",I,UID)=@GLOBALL@(UID) + . . L -@GLOBALL@(UID) + I $G(HTTPERR) QUIT + ; Set Result variable to global + S RESULT=$NA(^||TMP($J,"RESULT")) + K:$D(@RESULT) @RESULT + ; Encode object into JSON return + D ENCODE^VPRJSON(OBJECT,RESULT,"ERR") ; From an array to JSON + ; Clean up staging variable + K:$D(@OBJECT) @OBJECT + I $D(ERR) D SETERROR^VPRJRER(202) QUIT + QUIT + ; +SETLOCK(ARGS,BODY) + N FMNOW,TIMEOUT,FMLOCK,TIMEOUT,FMTIMEOUT,GLOBAL,GLOBALL,UID + ; Ensure the store is setup and correct + I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) QUIT "" + S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) + S GLOBALL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"L" + I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) QUIT "" + ; If there is no uid quit with an error + I $G(ARGS("uid"))="" D SETERROR^VPRJRER(111,"uid is blank") QUIT "" + S UID=ARGS("uid") + L +@GLOBALL@(UID):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502,"unable to get locktable lock") QUIT "" + ; If the uid doesn't have a lock: lock it and be done + I '$D(@GLOBALL@(UID)) S @GLOBALL@(UID)=$$CURRTIME^VPRJRUT L -@GLOBALL@(UID) QUIT "/"_HTTPREQ("store")_"/lock/"_ARGS("uid") + ; Calculate if the record is timedout + S FMNOW=$$HL7TFM^XLFDT($$CURRTIME^VPRJRUT) + S TIMEOUT=$G(^VPRCONFIG("store",HTTPREQ("store"),"lockTimeout")) + S FMLOCK=$$HL7TFM^XLFDT($G(@GLOBALL@(UID))) + S FMTIMEOUT=$$FMADD^XLFDT(FMLOCK,,,,TIMEOUT) + ; If the uid is currently locked and equal to or before the configured timeout error and be done + I $$FMDIFF^XLFDT(FMNOW,FMTIMEOUT,2)'>TIMEOUT D SETERROR^VPRJRER(272) L -@GLOBALL@(UID) QUIT "" + ; If the uid is currently locked and is after the configured timeout lock it and be done + I $$FMDIFF^XLFDT(FMNOW,FMTIMEOUT,2)>TIMEOUT S @GLOBALL@(UID)=$$CURRTIME^VPRJRUT L -@GLOBALL@(UID) QUIT "/"_HTTPREQ("store")_"/lock/"_ARGS("uid") + ; Should not get to this QUIT as all cases are above + ; This should cause a syntax error so any cases where it falls through can be caught + L -@GLOBALL@(UID) + QUIT + ; +DELLOCK(RESULT,ARGS) + N GLOBAL,GLOBALL + ; Ensure the store is setup and correct + I $G(HTTPREQ("store"))="" D SETERROR^VPRJRER(253) QUIT + S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) + S GLOBALL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"L" + I $L(GLOBAL)<2 D SETERROR^VPRJRER(253) QUIT + ; If there is no uid quit with an error + I $G(ARGS("uid"))="" D SETERROR^VPRJRER(111,"uid is blank") QUIT + ; Always removed the lock with the passed uid + I $D(@GLOBALL@(ARGS("uid"))) K @GLOBALL@(ARGS("uid")) + S RESULT="{""ok"": true}" + QUIT ; diff --git a/VPRJGDSN.m b/VPRJGDSN.m new file mode 100644 index 0000000..42cd52a --- /dev/null +++ b/VPRJGDSN.m @@ -0,0 +1,213 @@ +VPRJGDSN ;V4W/DLW -- Wrap CRUD calls to GDS REST endpoints for consumption by jdsClient using cache.node in jds-cache-api + ; + QUIT + ; + ; Create a new data store + ; + ; @param {string} STORE - Store name + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +CREATEDB(STORE) ; Called as createPjdsStore in pjds-client.js + N ARGS,BODY,HTTPERR,RESULT,URL,UUID + N LIMIT,RETCNTS,START,STARTID + ; + ; setup code + S ARGS("store")=$G(STORE) + D SETUP^VPRJUTLN + S BODY="" + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + S URL=$$CREATEDB^VPRJCONFIG(.ARGS,.BODY) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Clear a data store, including removing all of its data, indexes, templates, and remove the store itself + ; + ; @param {string} STORE - Store name + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +CLR(STORE) ; Called as clearPjdsStore in pjds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + N LIMIT,RETCNTS,START,STARTID + ; + ; setup code + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D CLR^VPRJGDS(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get information about a data store + ; + ; @param {string} STORE - Store name + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +INFO(STORE) ; Called as getPjdsStoreInfo in pjds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + N LIMIT,RETCNTS,START,STARTID + ; + ; setup code + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D INFO^VPRJGDS(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get a data item from a store by uid, or all data items from the store + ; + ; @param {string} STORE - Store name + ; @param {string} UID - Data item key to retrieve, or empty to retrieve all data items + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [SKIPLCKD="false"] - Whether to skip retrieving locked items [true|false] + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Whether to return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +GET(STORE,UID,TEMPLATE,ORDER,SKIPLCKD,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getPjdsStoreData in pjds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("uid")=$G(UID) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("skiplocked")=$G(SKIPLCKD,"false") + S ARGS("filter")=$G(FILTER) + S ARGS("startid")=$G(STARTID) + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D GET^VPRJGDS(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Add a data item to the store + ; + ; @param {string} STORE - Store name + ; @param {string} UID - Data item key to use for the new item, or empty to allow pJDS to assign one + ; @param {string} PATCH - Whether to allow updates to data items already stored [true|false] - requires a UID + ; @param {string} NODEUUID - UUID of the storage location of the data item to store (along with $JOB, it prevents races) + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +SET(STORE,UID,PATCH,NODEUUID) ; Called as setPjdsStoreData in pjds-client.js + N ARGS,BODY,HTTPREQ,HTTPERR,RESULT,URL,UUID + N LIMIT,RETCNTS,START,STARTID + ; + ; setup code + S ARGS("uid")=$G(UID) + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + I $G(PATCH)="true" S HTTPREQ("method")="PATCH" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + D STAGEDATA^VPRJUTLN(.BODY,NODEUUID) + ; + ; call endpoint + S URL=$$SET^VPRJGDS(.ARGS,.BODY) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Delete a data item from the store + ; + ; @param {string} STORE - Store name + ; @param {string} UID - Data item key to remove, or empty to allow remove all data items from store - requires DELETALL to be true + ; @param {string} DELETEALL - Whether to allow deleting every data item [true|false] - requires UID to be empty + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +DEL(STORE,UID,DELETEALL,FILTER) ; Called as deletePjdsStoreData in pjds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + N LIMIT,RETCNTS,START,STARTID + ; + ; setup code + S ARGS("uid")=$G(UID) + S ARGS("confirm")=$G(DELETEALL,"false") + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D DEL^VPRJGDS(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Add a new index on a data store + ; + ; @param {string} STORE - Store name + ; @param {string} NODEUUID - UUID of the storage location of the data item to store (along with $JOB, it prevents races) + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +CINDEX(STORE,NODEUUID) ; Called as createPjdsStoreIndex in pjds-client.js + N ARGS,BODY,HTTPREQ,HTTPERR,RESULT,URL,UUID + N LIMIT,RETCNTS,START,STARTID + ; + ; setup code + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + D STAGEDATA^VPRJUTLN(.BODY,NODEUUID) + ; + ; call endpoint + S URL=$$CINDEX^VPRJGDS(.ARGS,.BODY) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get items by index + ; + ; @param {string} STORE - Store name + ; @param {string} IDXNAME - Index name + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [RANGE=""] - A range of keys to limit the items being retrieved by index + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} [SKIPLCKD="false"] - Whether to skip retrieving locked items [true|false] + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Whether to return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +INDEX(STORE,IDXNAME,TEMPLATE,ORDER,RANGE,BAIL,SKIPLCKD,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getPjdsStoreIndex in pjds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("indexName")=$G(IDXNAME) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("range")=$G(RANGE) + S ARGS("bail")=$G(BAIL) + S ARGS("skiplocked")=$G(SKIPLCKD,"false") + S ARGS("filter")=$G(FILTER) + S ARGS("startid")=$G(STARTID) + S HTTPREQ("store")=$$LOW^VPRJRUT($G(STORE)) + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D INDEX^VPRJGDS(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; diff --git a/VPRJGDSQ.m b/VPRJGDSQ.m index 16ccaa8..5d736de 100644 --- a/VPRJGDSQ.m +++ b/VPRJGDSQ.m @@ -10,10 +10,10 @@ S GLOBALJ="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"J" ; I '$D(@GLOBALJ("JSON",KEY)) D SETERROR^VPRJRER(104,"UID:"_KEY) Q - K ^TMP("VPRDATA",$J) - S ^TMP("VPRDATA",$J,KEY,0)="",VPRDATA=1,ORDER(0)=0 + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) + S ^||TMP("VPRDATA",$J,KEY,0)="",VPRDATA=1,ORDER(0)=0 D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q ; QCOUNT(CNTNM) ; Return a set of counts across patients @@ -25,7 +25,7 @@ ; Index S GLOBALX="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"X" ; - K ^TMP($J) + K:$D(^||TMP($J)) ^||TMP($J) ; N TOPIC,DATA,COUNT,X S DATA=0,TOPIC="" @@ -68,7 +68,7 @@ ; FILTER: criteria statement to further limit returned results ; CLAUSES: clauses to apply filter to each object ; -QINDEX(INDEX,RANGE,ORDER,BAIL,TEMPLATE,FILTER) ; query based on index +QINDEX(INDEX,RANGE,ORDER,BAIL,TEMPLATE,FILTER,SKIPLOCK) ; query based on index I '$L($G(INDEX)) D SETERROR^VPRJRER(101) Q N VPRDATA,METHOD,CLAUSES S RANGE=$G(RANGE),ORDER=$G(ORDER),BAIL=$G(BAIL),TEMPLATE=$G(TEMPLATE),FILTER=$G(FILTER) @@ -77,10 +77,10 @@ S METHOD=$G(INDEX("method")) I '$L(METHOD) D SETERROR^VPRJRER(102,INDEX) Q I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) D SETORDER^VPRJCO(.ORDER) Q:$G(HTTPERR) - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) I METHOD="attr" D QATTR^VPRJGDSQA D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q QLAST(INDEX,RANGE,ORDER,BAIL,TEMPLATE,FILTER) ; return most recent item in the list Q ; NOT IMPLEMENTED @@ -94,9 +94,9 @@ D QINDEX(INDEX,$G(RANGE),$G(ORDER),$G(BAIL),$G(TEMPLATE),$G(FILTER)) S VPRDATA=0 S:'BAIL BAIL=999999 I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) D SETORDER^VPRJCO(.ORDER) Q:$G(HTTPERR) - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) S PREFIX="urn:va:"_COLL_":",KEY=PREFIX F S KEY=$O(^VPRJD(KEY)) Q:$E(KEY,1,$L(PREFIX))'=PREFIX D ADDONE^VPRJGDSQA(KEY,0) D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q diff --git a/VPRJGDSQA.m b/VPRJGDSQA.m index 78f1bcb..502f70c 100644 --- a/VPRJGDSQA.m +++ b/VPRJGDSQA.m @@ -1,5 +1,4 @@ VPRJGDSQA ;SLC/KCM/CJE -- Query using attribute indexes for JSON objects - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; ;defined at the QINDEX level: ; INDEX: Name of the index @@ -11,13 +10,15 @@ ; CLAUSES: clauses to apply filter to each object ; QATTR ; return items where attribute value is in range - ; Build ^TMP("VPRDATA",$J,sortkey,sortkey,...,key,instances) with keys of objects to return + ; Build ^||TMP("VPRDATA",$J,sortkey,sortkey,...,key,instances) with keys of objects to return ; Expects: VPRDATA,METHOD,RANGE,INDEX,ORDER,CLAUSES,BAIL N START,STOP,DIR,SUB,KEY,INST,GLOBAL,GLOBALX ; Parsed JSON S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) ; Index S GLOBALX="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"X" + ; Lock table + S GLOBALL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"L" ; D PARSERNG^VPRJCR I $G(IDXLAST)=1 D ; handle finding last or latest items @@ -33,25 +34,25 @@ . I INDEX("levels")=3 D A3 Q Q A0 ; unsorted list - S KEY="" F S KEY=$O(@GLOBALX@(METHOD,INDEX,KEY)) Q:KEY="" Q:VPRDATA'TIMEOUT)&(($$FMDIFF^XLFDT(FMTIMEOUT,FMNOW,2)>0))&($G(SKIPLOCK))) QUIT + ; Remove the entry from the lock table and return the data + I ('$D(@GLOBALL@(KEY)))!($$FMDIFF^XLFDT(FMTIMEOUT,FMNOW,2)>TIMEOUT) K:$D(@GLOBALL@(KEY)) @GLOBALL@(KEY) N I,SORT,KINST - S I=0 F S I=$O(ORDER(I)) Q:'I S SORT(I)=$S(+ORDER(I):SUB(+ORDER(I)),1:$$SORTVAL(I)) + S I=0 F S I=$O(ORDER(I)) Q:'I S SORT(I)=$S(+ORDER(I):SUB(+ORDER(I)),1:$$SORTVAL(I)) S:ORDER(I,"nocase") SORT(I)=$$LOW^XLFSTR(SORT(I)) S VPRDATA=VPRDATA+1 ; case - I ORDER(0)=0 S:'$D(^TMP("VPRDATA",$J,KEY)) ^TMP("VPRDATA",$J,KEY,INST)="" G X1 - I ORDER(0)=1 S:'$D(^TMP("VPRDATA",$J,SORT(1),KEY)) ^TMP("VPRDATA",$J,SORT(1),KEY,INST)="" G X1 - I ORDER(0)=2 S:'$D(^TMP("VPRDATA",$J,SORT(1),SORT(2),KEY)) ^TMP("VPRDATA",$J,SORT(1),SORT(2),KEY,INST)="" G X1 - I ORDER(0)=3 S:'$D(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY)) ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY,INST)="" G X1 - I ORDER(0)=4 S:'$D(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY)) ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY,INST)="" G X1 - I ORDER(0)=5 S:'$D(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY)) ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY,INST)="" G X1 - I ORDER(0)=6 S:'$D(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY)) ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY,INST)="" G X1 - I ORDER(0)=7 S:'$D(^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY)) ^TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY,INST)="" G X1 + I ORDER(0)=0 S:'$D(^||TMP("VPRDATA",$J,KEY)) ^||TMP("VPRDATA",$J,KEY,INST)="" G X1 + I ORDER(0)=1 S:'$D(^||TMP("VPRDATA",$J,SORT(1),KEY)) ^||TMP("VPRDATA",$J,SORT(1),KEY,INST)="" G X1 + I ORDER(0)=2 S:'$D(^||TMP("VPRDATA",$J,SORT(1),SORT(2),KEY)) ^||TMP("VPRDATA",$J,SORT(1),SORT(2),KEY,INST)="" G X1 + I ORDER(0)=3 S:'$D(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY)) ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),KEY,INST)="" G X1 + I ORDER(0)=4 S:'$D(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY)) ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),KEY,INST)="" G X1 + I ORDER(0)=5 S:'$D(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY)) ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),KEY,INST)="" G X1 + I ORDER(0)=6 S:'$D(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY)) ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),KEY,INST)="" G X1 + I ORDER(0)=7 S:'$D(^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY)) ^||TMP("VPRDATA",$J,SORT(1),SORT(2),SORT(3),SORT(4),SORT(5),SORT(6),SORT(7),KEY,INST)="" G X1 X1 ; end case - Q + QUIT ; SORTVAL(LEVEL) ; return a value or 0 from data gbl for sorting ; Expects: KEY,INST,.ORDER derived from GETVALS^VPRJCV diff --git a/VPRJGDSX.m b/VPRJGDSX.m index 2a7ccca..e00dc2c 100644 --- a/VPRJGDSX.m +++ b/VPRJGDSX.m @@ -62,7 +62,7 @@ D STALLY(.NEWOBJ) D IDXVALS^VPRJCV(.OBJECT,.VALUES,.IDXMETA) Q:'$D(VALUES) S I="" F S I=$O(VALUES(I)) Q:I="" D . S TALLY=$I(@GLOBALX@("tally",IDXNAME,VALUES(I,1)),-1) - . I @GLOBALX@("tally",IDXNAME,VALUES(I,1))=0 K ^VPRJDX("tally",IDXNAME,VALUES(I,1)) + . I @GLOBALX@("tally",IDXNAME,VALUES(I,1))=0 K:$D(^VPRJDX("tally",IDXNAME,VALUES(I,1))) ^VPRJDX("tally",IDXNAME,VALUES(I,1)) Q ; ; ----- Index Logic: attributes ----- @@ -99,8 +99,8 @@ I IDXMETA("levels")=3 D SA3 Q I $L(IDXMETA("review")) D . N REVTM . S REVTM=$G(@GLOBALX@("keyReview",KEY,IDXNAME)) Q:'$L(REVTM) - . K @GLOBALX@("keyReview",KEY,IDXNAME) - . K @GLOBALX@("review",REVTM,KEY,IDXNAME) + . K:$D(@GLOBALX@("keyReview",KEY,IDXNAME)) @GLOBALX@("keyReview",KEY,IDXNAME) + . K:$D(@GLOBALX@("review",REVTM,KEY,IDXNAME)) @GLOBALX@("review",REVTM,KEY,IDXNAME) ; I IDXMETA("levels")=0 D KA0 Q ; @@ -114,25 +114,25 @@ I IDXMETA("levels")=3 D KA3 Q S @GLOBALX@("attr",IDXNAME,KEY)="" Q KA0 ; unsorted list kill logic - K @GLOBALX@("attr",IDXNAME,KEY) + K:$D(@GLOBALX@("attr",IDXNAME,KEY)) @GLOBALX@("attr",IDXNAME,KEY) Q SA1 ; one attribute set logic S I="" F S I=$O(VALUES(I)) Q:I="" S @GLOBALX@("attr",IDXNAME,VALUES(I,1),KEY,I)="" Q KA1 ; one attribute kill logic - S I="" F S I=$O(VALUES(I)) Q:I="" K @GLOBALX@("attr",IDXNAME,VALUES(I,1),KEY,I) + S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(@GLOBALX@("attr",IDXNAME,VALUES(I,1),KEY,I)) @GLOBALX@("attr",IDXNAME,VALUES(I,1),KEY,I) Q SA2 ; two attributes set logic S I="" F S I=$O(VALUES(I)) Q:I="" S @GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)="" Q KA2 ; two attributes kill logic - S I="" F S I=$O(VALUES(I)) Q:I="" K @GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I) + S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(@GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)) @GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I) Q SA3 ; three attributes set logic S I="" F S I=$O(VALUES(I)) Q:I="" S @GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)="" Q KA3 ; three attributes kill logic - S I="" F S I=$O(VALUES(I)) Q:I="" K @GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I) + S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(@GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)) @GLOBALX@("attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I) Q ; REVERSE ; REV index @@ -151,5 +151,5 @@ D SREVERSE(.NEWOBJ) Q:$D(OBJECT)<10 N VALUES,I D IDXVALS^VPRJCV(.OBJECT,.VALUES,.IDXMETA) Q:'$D(VALUES) - S I="" F S I=$O(VALUES(I)) Q:I="" K @GLOBALX@("rev",VALUES(I,1),IDXNAME,KEY,I) + S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(@GLOBALX@("rev",VALUES(I,1),IDXNAME,KEY,I)) @GLOBALX@("rev",VALUES(I,1),IDXNAME,KEY,I) Q diff --git a/VPRJOB.m b/VPRJOB.m old mode 100755 new mode 100644 index c8ca676..5eaf565 --- a/VPRJOB.m +++ b/VPRJOB.m @@ -1,6 +1,4 @@ -VPRJOB ;CNP/JD -- Handle Job operations ;2015-04-15 8:33 PM - ;;1.0;JSON DATA STORE;;Dec 02, 2014 - ;;Dec 09, 2014 +VPRJOB ;CNP/JD -- Handle Job operations ; Q ; @@ -28,8 +26,9 @@ S VPRTS=$G(DEMOG("timestamp")) I VPRTS="" D SETERROR^VPRJRER(235) Q "" ; + ; The job may contain a JPID. We will purposely ignore/re-set it as it can be a VX-Sync generated + ; UUID v4 and not a JPID that JDS generated ; Make sure we have a patient identifier - S JPID=$G(DEMOG("jpid")) I $G(DEMOG("patientIdentifier","type"))="pid" S PID=$G(DEMOG("patientIdentifier","value")) I $G(DEMOG("patientIdentifier","type"))="icn" S ICN=$G(DEMOG("patientIdentifier","value")) ; If what we are passed isn't a JPID get a JPID @@ -37,6 +36,7 @@ I $G(PID)'="" S JPID=$$JPID4PID^VPRJPR(PID) ; A JPID should exist by now if not error out I $G(JPID)="" D SETERROR^VPRJRER(231) Q "" + S DEMOG("jpid")=JPID ; Ensure we know jpid I '$$JPIDEXISTS^VPRJPR(JPID) D SETERROR^VPRJRER(224) Q "" ; @@ -45,11 +45,21 @@ S VPRA=$O(^VPRJOB("C",JID,"")) I VPRA,(RJID'=VPRA) D SETERROR^VPRJRER(236) Q "" S VPRCNT=$I(^VPRJOB(0)) + L +^VPRJOB(VPRCNT) + L +^VPRJOB("A",JPID,JTYPE,RJID,JID,VPRTS,JSTAT) + L +^VPRJOB("B",VPRCNT) + L +^VPRJOB("C",JID,RJID) + L +^VPRJOB("D",JPID,JTYPE,VPRTS,VPRCNT) S ^VPRJOB("A",JPID,JTYPE,RJID,JID,VPRTS,JSTAT)=VPRCNT S ^VPRJOB("B",VPRCNT)=JPID_U_JTYPE_U_RJID_U_JID_U_VPRTS_U_JSTAT S ^VPRJOB("C",JID,RJID)="" S ^VPRJOB("D",JPID,JTYPE,VPRTS,VPRCNT)=VPRCNT M ^VPRJOB(VPRCNT)=DEMOG + L -^VPRJOB(VPRCNT) + L -^VPRJOB("A",JPID,JTYPE,RJID,JID,VPRTS,JSTAT) + L -^VPRJOB("B",VPRCNT) + L -^VPRJOB("C",JID,RJID) + L -^VPRJOB("D",JPID,JTYPE,VPRTS,VPRCNT) Q "" ; GET(RESULT,ARGS,ENCODE,TEMPLATE) ; Return job info @@ -90,8 +100,9 @@ . N TIMESTAMP,COUNTER . S TIMESTAMP="" . S TIMESTAMP=$O(^VPRJOB("D",JPID,"enterprise-sync-request",TIMESTAMP),-1) - . S COUNTER=$O(^VPRJOB("D",JPID,"enterprise-sync-request",TIMESTAMP,"")) - . M DEMOG("items",COUNTER)=^VPRJOB(COUNTER) + . I TIMESTAMP'="" D + . . S COUNTER=$O(^VPRJOB("D",JPID,"enterprise-sync-request",TIMESTAMP,"")) + . . M DEMOG("items",COUNTER)=^VPRJOB(COUNTER) ; E D . ; Loop through A index @@ -118,24 +129,12 @@ . . . . I $D(CLAUSES) D Q . . . . . ; Ensure we only run this for the last timestamp for the JPID and job type . . . . . I VPRC'=$O(^VPRJOB("D",JPID,JTYPE,""),-1) Q - . . . . . N I - . . . . . S I="" - . . . . . ; Loop through all of the clauses we have - . . . . . F S I=$O(CLAUSES(I)) Q:I="" D - . . . . . . M CLAUSE=CLAUSES(I) - . . . . . . N FILTERRSLT - . . . . . . I CLAUSE("type")=1 D - . . . . . . . I $D(^VPRJOB(VPRA,CLAUSE("field")))\10 D - . . . . . . . . S FIELD="" - . . . . . . . . F S FIELD=$O(^VPRJOB(VPRA,CLAUSE("field"),FIELD),-1) D Q:FIELD="" Q:VALUE'="" - . . . . . . . . . S VALUE=$G(^VPRJOB(VPRA,CLAUSE("field"),FIELD)) - . . . . . . . E D - . . . . . . . . S VALUE=$G(^VPRJOB(VPRA,CLAUSE("field"))) - . . . . . . . S FILTERRSLT=$$EVALONE^VPRJCF D:FILTERRSLT - . . . . . . . . M:'$D(TEMPLATE) DEMOG("items",VPRA)=^VPRJOB(VPRA) - . . . . . . . . I $D(TEMPLATE) N FIELD S FIELD="" F S FIELD=$O(TEMPLATE(FIELD)) Q:FIELD="" D - . . . . . . . . . I FIELD'["." M DEMOG("items",VPRA,FIELD)=^VPRJOB(VPRA,FIELD) - . . . . . . . . . E M DEMOG("items",VPRA,$P(FIELD,".",1),$P(FIELD,".",2))=^VPRJOB(VPRA,$P(FIELD,".",1),$P(FIELD,".",2)) + . . . . . ; Evaluate CLAUSES in an implicit AND clause + . . . . . Q:'$$EVALAND^VPRJGQF(.CLAUSES,$NA(^VPRJOB(VPRA))) + . . . . . M:'$D(TEMPLATE) DEMOG("items",VPRA)=^VPRJOB(VPRA) + . . . . . I $D(TEMPLATE) N FIELD S FIELD="" F S FIELD=$O(TEMPLATE(FIELD)) Q:FIELD="" D + . . . . . . I FIELD'["." M DEMOG("items",VPRA,FIELD)=^VPRJOB(VPRA,FIELD) + . . . . . . E M DEMOG("items",VPRA,$P(FIELD,".",1),$P(FIELD,".",2))=^VPRJOB(VPRA,$P(FIELD,".",1),$P(FIELD,".",2)) . . . . ; . . . . ; Return jobs without filter . . . . ; If we have a rootJobId and JobId and TimeStamp and they match return the Job @@ -156,7 +155,7 @@ I '$G(ENCODE),$D(ERR) D SETERROR^VPRJRER(202) Q Q CLEAR(RESULT,ARGS) ; Delete all job state data - K ^VPRJOB + K:$D(^VPRJOB) ^VPRJOB Q DEL(PID) ; Delete all job statuses for a PID ; Get the JPID for a PID as Job status depends on JPID @@ -179,15 +178,15 @@ . . . . . ; Get the sequential counter . . . . . S SC=$G(^VPRJOB("A",JPID,JTYPE,RJID,JID,TS,STATUS)) . . . . . ; Kill the data - . . . . . K ^VPRJOB(SC) + . . . . . K:$D(^VPRJOB(SC)) ^VPRJOB(SC) . . . . . ; Kill the D index - . . . . . K ^VPRJOB("D",JPID,JTYPE) + . . . . . K:$D(^VPRJOB("D",JPID,JTYPE)) ^VPRJOB("D",JPID,JTYPE) . . . . . ; Kill the C index - . . . . . K ^VPRJOB("C",JID,RJID) + . . . . . K:$D(^VPRJOB("C",JID,RJID)) ^VPRJOB("C",JID,RJID) . . . . . ; Kill the B index - . . . . . K ^VPRJOB("B",SC) + . . . . . K:$D(^VPRJOB("B",SC)) ^VPRJOB("B",SC) . . . . . ; Kill the A index - . . . . . K ^VPRJOB("A",JPID,JTYPE,RJID,JID,TS,STATUS) + . . . . . K:$D(^VPRJOB("A",JPID,JTYPE,RJID,JID,TS,STATUS)) ^VPRJOB("A",JPID,JTYPE,RJID,JID,TS,STATUS) Q ; DELJID(RESULT,ARGS) ; REST entry point to delete a job id @@ -210,17 +209,17 @@ . . . . . ; Get the sequential counter . . . . . S SC=$G(^VPRJOB("A",JPID,JTYPE,RJID,JID,TS,STATUS)) . . . . . ; Kill the data - . . . . . K ^VPRJOB(SC) + . . . . . K:$D(^VPRJOB(SC)) ^VPRJOB(SC) . . . . . ; Kill the B index - . . . . . K ^VPRJOB("B",SC) + . . . . . K:$D(^VPRJOB("B",SC)) ^VPRJOB("B",SC) . . . . . ; Kill the D index - . . . . . K ^VPRJOB("D",JPID,JTYPE,TS,SC) + . . . . . K:$D(^VPRJOB("D",JPID,JTYPE,TS,SC)) ^VPRJOB("D",JPID,JTYPE,TS,SC) . . . ; Needs to be killed outside the inner two loops, as it is being iterated . . . ; Kill the A index - . . . K ^VPRJOB("A",JPID,JTYPE,RJID,JID) + . . . K:$D(^VPRJOB("A",JPID,JTYPE,RJID,JID)) ^VPRJOB("A",JPID,JTYPE,RJID,JID) ; Don't keep killing the same nodes over and over in all the inner loops ; Kill the C index - K ^VPRJOB("C",JID) + K:$D(^VPRJOB("C",JID)) ^VPRJOB("C",JID) S RESULT="{}" Q ; @@ -240,11 +239,11 @@ . . S JID=^VPRJOB(SC,"jobId") . . S STAMP=^VPRJOB(SC,"timestamp") . . ; - . . K ^VPRJOB("A",JPID,TYPE,RJID,JID,STAMP) - . . K ^VPRJOB("B",SC) - . . K ^VPRJOB("C",JID,RJID) - . . K ^VPRJOB("D",JPID,TYPE,STAMP) - . . K ^VPRJOB(SC) + . . K:$D(^VPRJOB("A",JPID,TYPE,RJID,JID,STAMP)) ^VPRJOB("A",JPID,TYPE,RJID,JID,STAMP) + . . K:$D(^VPRJOB("B",SC)) ^VPRJOB("B",SC) + . . K:$D(^VPRJOB("C",JID,RJID)) ^VPRJOB("C",JID,RJID) + . . K:$D(^VPRJOB("D",JPID,TYPE,STAMP)) ^VPRJOB("D",JPID,TYPE,STAMP) + . . K:$D(^VPRJOB(SC)) ^VPRJOB(SC) Q DELETE(RESULT,ARGS) ; REST entry point wrapper for DEL^VPRJOB N PID diff --git a/VPRJODM.m b/VPRJODM.m old mode 100755 new mode 100644 index 1eb68a1..d816c22 --- a/VPRJODM.m +++ b/VPRJODM.m @@ -14,7 +14,7 @@ L +^VPRJODM(SID):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q "" TSTART I $O(^VPRJODM(SID,""))']"" S ^VPRJODM(0)=$G(^VPRJODM(0))+1 - K ^VPRJODM(SID) + K:$D(^VPRJODM(SID)) ^VPRJODM(SID) M ^VPRJODM(SID)=OBJECT TCOMMIT L -^VPRJODM(SID) @@ -26,7 +26,7 @@ L +^VPRJODM:$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q S VPRJA=0 TSTART - F S VPRJA=$O(^VPRJODM(VPRJA)) Q:VPRJA']"" K ^VPRJODM(VPRJA) + F S VPRJA=$O(^VPRJODM(VPRJA)) Q:VPRJA']"" K:$D(^VPRJODM(VPRJA)) ^VPRJODM(VPRJA) S ^VPRJODM(0)=0 TCOMMIT L -^VPRJODM @@ -39,7 +39,7 @@ I $D(^VPRJODM(ARGS("_id"))) D .L +^VPRJODM(ARGS("_id")):$G(^VPRCONFIG("timeout","gds"),5) .TSTART - .K ^VPRJODM(ARGS("_id")) + .K:$D(^VPRJODM(ARGS("_id"))) ^VPRJODM(ARGS("_id")) .TCOMMIT .L -^VPRJODM(ARGS("_id")) S RESULT="{}" diff --git a/VPRJPMD.m b/VPRJPMD.m old mode 100755 new mode 100644 index 3a2cdce..f861a9f --- a/VPRJPMD.m +++ b/VPRJPMD.m @@ -1,8 +1,10 @@ VPRJPMD ;SLC/KCM -- Set up Meta Data for VPR Indexing - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; SETUP ; - K ^VPRMETA + M ^VPRSAVE("lastAccessTime")=^VPRMETA("JPID") ; save off lastAccessTime data + K:$D(^VPRMETA) ^VPRMETA + M ^VPRMETA("JPID")=^VPRSAVE("lastAccessTime") ; restore lastAccessTime data + K:$D(^VPRSAVE("lastAccessTime")) ^VPRSAVE("lastAccessTime") S ^VPRMETA("system")=$$SYSID^VPRJRUT() S ^VPRMETA("version")=$P($T(VERSION^VPRJVER),";;",2) S ^VPRMETA("version","build")=$P($T(BUILD^VPRJVER),";;",2) @@ -13,6 +15,15 @@ D BLDMETA^VPRJCD("template","TLT","VPRJDMT") ; ODC templates D BLDMETA^VPRJCD("link","LINKED","VPRJPMR") ; VPR and ODC linkages ; + ; Generic Data Store Templates + N STORE,TEMPLATE + S STORE="" + S TEMPLATE="" + F S STORE=$O(^VPRCONFIG("store",STORE)) Q:STORE="" D + . F S TEMPLATE=$O(^VPRCONFIG("store",STORE,"template",TEMPLATE)) Q:TEMPLATE="" D + . . M ^VPRMETA("template")=^VPRCONFIG("store",STORE,"template",TEMPLATE) + . . S ^VPRMETA("collection",STORE,"template",TEMPLATE)="" + ; ; "every" index is special index that references all the UID's for a patient S ^VPRMETA("index","every")="every" S ^VPRMETA("index","every","common","levels")=0 @@ -35,8 +46,8 @@ L -^VPRPTJ("JPID") Q INDEXES ; -- build meta data for all indexes - K ^VPRMETA("index") - K ^VPRMETA("collection") + K:$D(^VPRMETA("index")) ^VPRMETA("index") + K:$D(^VPRMETA("collection")) ^VPRMETA("collection") ; ; Patient Indexes D BLDMETA^VPRJCD("index:attr","IDXLIST","VPRJPMX") diff --git a/VPRJPMR.m b/VPRJPMR.m old mode 100755 new mode 100644 diff --git a/VPRJPMT.m b/VPRJPMT.m old mode 100755 new mode 100644 diff --git a/VPRJPMX.m b/VPRJPMX.m old mode 100755 new mode 100644 index 97eb3f7..acdf515 --- a/VPRJPMX.m +++ b/VPRJPMX.m @@ -1,5 +1,4 @@ VPRJPMX ;SLC/KCM -- Meta data for JSON indexes - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; ; Types of collation: ; V: Inverse HL7 Time (appends "=" after complementing time) @@ -23,6 +22,7 @@ ;; collections: allergy ;; fields: ;; sort: + ;; setif: $$NRMVD^VPRJFPS ;;consult ;; collections: consult ;; fields: dateTime/V/0 @@ -53,6 +53,7 @@ ;; collections: immunization ;; fields: administeredDateTime/V/0 ;; sort: administeredDateTime desc + ;; setif: $$NRMVD^VPRJFPS ;;laboratory ;; collections: lab ;; fields: observed/V/0 @@ -98,6 +99,7 @@ ;; collections: problem ;; fields: ;; sort: + ;; setif: $$NRMVD^VPRJFPS ;;problem-active ;; collections: problem ;; fields: onset/V/0 @@ -137,6 +139,11 @@ ;; fields: referenceDateTime/V/0 ;; sort: referenceDateTime desc ;; setif: $$CWAD^VPRJFPS + ;;cwad-kind + ;; collections: document, allergy, alert + ;; fields: kind/s, referenceDateTime/V/0 + ;; sort: referenceDateTime desc + ;; setif: $$CWADNRMVD^VPRJFPS ;;med-active-inpt ;; collections: med ;; fields: overallStop/V/9 @@ -299,7 +306,7 @@ ; The first collation is the field collation, followed by the sort collation. ; The default is s,s (both case-insensitive strings) if no other collation ; is defined. -IDXATTR ; +IDXATTR ; attribute type indexes ;;utest ;; collections: utesta, utestb ;; fields: @@ -384,6 +391,13 @@ ;; fields.lab: observed ;; sort: datetime desc ;; setif: $$ALLDOC^VPRJFPS + ;;ehmp-documents + ;; collections: consult,document,procedure,surgery,image + ;; fields: dateTime/V, statusName, kind + ;; fields.document: referenceDateTime, status, kind + ;; fields.lab: observed, statusName, kind + ;; sort: datetime desc + ;; setif: $$EHMPDOC^VPRJFPS ;;zzzzz ; ; -------------------------------------------------------- diff --git a/VPRJPQ.m b/VPRJPQ.m old mode 100755 new mode 100644 index b1e9aed..0a3bfbd --- a/VPRJPQ.m +++ b/VPRJPQ.m @@ -11,10 +11,10 @@ I JPID="" D SETERROR^VPRJRER(222,"Identifier "_PID) Q ; I '$D(^VPRPTJ("JSON",JPID,PID,KEY)) D SETERROR^VPRJRER(104,"Pid:"_PID_" Key:"_KEY) Q - K ^TMP("VPRDATA",$J) - S ^TMP("VPRDATA",$J,KEY,0)=PID,VPRDATA=1,ORDER(0)=0 + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) + S ^||TMP("VPRDATA",$J,KEY,0)=PID,VPRDATA=1,ORDER(0)=0 D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q ; QTALLY(PID,CNTNM) ; Return a set of counts @@ -73,12 +73,12 @@ I '$L($G(INDEX)) D SETERROR^VPRJRER(101) Q N VPRDATA,METHOD,CLAUSES S RANGE=$G(RANGE),ORDER=$G(ORDER),BAIL=$G(BAIL),TEMPLATE=$G(TEMPLATE),FILTER=$G(FILTER) - S VPRDATA=+$G(^TMP($J,"total")) S:'BAIL BAIL=999999 + S VPRDATA=+$G(^||TMP($J,"total")) S:'BAIL BAIL=999999 M INDEX=^VPRMETA("index",INDEX,"common") S METHOD=$G(INDEX("method")) I '$L(METHOD) D SETERROR^VPRJRER(102,INDEX) Q I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) D SETORDER^VPRJCO(.ORDER) Q:$G(HTTPERR) - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) I $$ISJPID^VPRJPR(PID) D . ; We were handed a JPID convert to PID(s) and add to result . N PIDS,ID @@ -96,15 +96,15 @@ . I METHOD="attr" D QATTR^VPRJPQA . I METHOD="every" D QEVERY^VPRJPQA D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q QFIND(PID,COLL,ORDER,BAIL,TEMPLATE,FILTER) ; return items from collection without index N VPRDATA,CLAUSES,PREFIX,KEY S ORDER=$G(ORDER),BAIL=$G(BAIL),TEMPLATE=$G(TEMPLATE),FILTER=$G(FILTER) - S VPRDATA=+$G(^TMP($J,"total")) S:'BAIL BAIL=999999 + S VPRDATA=+$G(^||TMP($J,"total")) S:'BAIL BAIL=999999 I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) D SETORDER^VPRJCO(.ORDER) Q:$G(HTTPERR) - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) S PREFIX="urn:va:"_COLL_":",KEY=PREFIX I $$ISJPID^VPRJPR(PID) D . ; We were handed a JPID convert to PID(s) and add to result @@ -125,7 +125,7 @@ . N JPID S JPID=$$JPID4PID^VPRJPR(PID) Q:JPID="" . F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:$E(KEY,1,$L(PREFIX))'=PREFIX D ADDONE^VPRJPQA(KEY,0) D BUILD^VPRJCB - K ^TMP("VPRDATA",$J) + K:$D(^||TMP("VPRDATA",$J)) ^||TMP("VPRDATA",$J) Q QLAST(PID,INDEX,RANGE,ORDER,BAIL,TEMPLATE,FILTER) ; return most recent item in the list N IDXLAST S IDXLAST=1 diff --git a/VPRJPQA.m b/VPRJPQA.m old mode 100755 new mode 100644 index ec67bd6..75a6b9f --- a/VPRJPQA.m +++ b/VPRJPQA.m @@ -20,7 +20,7 @@ S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" Q:VPRDATA' JPID) S ^VPRPTJ("JPID",ID)=JPID Q + ; JPIDDIDX(JPID,ID) ; Remove passed identifier from JPID index - I JPID="" Q - I ID="" Q + I JPID="" QUIT + I ID="" QUIT N PCNT ; Kill the JPID forward lookup index (JPID -> PID/ICN) - K ^VPRPTJ("JPID",JPID,ID) + K:$D(^VPRPTJ("JPID",JPID,ID)) ^VPRPTJ("JPID",JPID,ID) ; Kill the JPID reverse lookup index (PID/ICN -> JPID) - K ^VPRPTJ("JPID",ID) -JPIDCLN - ; Remove the existance of the JPID if no children remain + K:$D(^VPRPTJ("JPID",ID)) ^VPRPTJ("JPID",ID) + ; Remove the existence of the JPID if no children remain N PCNT I $D(^VPRPTJ("JPID",JPID))=1 D - . K ^VPRPTJ("JPID",JPID) + . K:$D(^VPRPTJ("JPID",JPID)) ^VPRPTJ("JPID",JPID) . S PCNT=$G(^VPRPTX("count","patient","patient"),0) . I PCNT'=0 S ^VPRPTX("count","patient","patient")=PCNT-1 - Q + QUIT + ; JPID4PID(PID) ; Return JPID for a PID I $G(PID)="" Q "" ; Quit if PID is empty I $$ISJPID(PID) Q PID ; Passed PID is a JPID @@ -473,9 +473,9 @@ D PID4JPID(.PIDS,JPID) . S BODY("patientIdentifiers",I)=PIDS(PID) S BODY("jpid")=JPID ; Encode the response - D ENCODE^VPRJSON("BODY","^TMP($J)","ERR") I $D(ERR) D SETERROR^VPRJRER(202) Q + D ENCODE^VPRJSON("BODY","^||TMP($J)","ERR") I $D(ERR) D SETERROR^VPRJRER(202) Q ; return results global - S RESULT=$NA(^TMP($J)) + S RESULT=$NA(^||TMP($J)) Q ; ASSOCIATE(ARGS,BODY) ; Associate a PID/ICN with a JPID @@ -483,7 +483,7 @@ S BODY("jpid")=JPID N OBJECT,ERR,JPID,UID,PID,ICN,EPID,EJPID,NEWJPID,I,CONFLICTICN,ERR I $G(ARGS("ewdjs"),0)=1 D . M OBJECT=BODY - E D I $D(ERR) D SETERROR^VPRJRER(202) Q "" + E D I $D(ERR) D SETERROR^VPRJRER(202) QUIT "" . ; Decode Body JSON to M object . D DECODE^VPRJSON("BODY","OBJECT","ERR") ; Ensure JPID variable exists @@ -496,11 +496,11 @@ S BODY("jpid")=JPID ; We will check the identifiers given later to check for collisions I JPID="" S JPID=$$JPID ; Sanity check - if a client posts to a jpid and includes a different one in the body error - I $G(ARGS("jpid"))'="",$G(OBJECT("jpid"))'="" I $G(ARGS("jpid"))'=$G(OBJECT("jpid")) D SETERROR^VPRJRER(205) Q "" + I $G(ARGS("jpid"))'="",$G(OBJECT("jpid"))'="" I $G(ARGS("jpid"))'=$G(OBJECT("jpid")) D SETERROR^VPRJRER(205) QUIT "" ; Sanity check - make sure we know jpid - I $G(^VPRPTJ("JPID",JPID)) D SETERROR^VPRJRER(224) Q "" + I $G(^VPRPTJ("JPID",JPID)) D SETERROR^VPRJRER(224) QUIT "" ; Ensure required attributes are defined - I '$D(OBJECT("patientIdentifiers")) D SETERROR^VPRJRER(211) Q "" + I '$D(OBJECT("patientIdentifiers")) D SETERROR^VPRJRER(211) QUIT "" ; Check to make sure we don't know these patient IDs on another patient S EPID="" F I=1:1 S EPID=$O(OBJECT("patientIdentifiers",EPID)) Q:EPID="" D @@ -509,21 +509,25 @@ S BODY("jpid")=JPID . ; If EJPID is blank we don't know this PID it is ok . I EJPID="" Q . ; If we have an EJPID we know this PID, ensure it matches the one on file, if it doesn't match error - . I JPID'=EJPID D SETERROR^VPRJRER(223,"Identifier "_OBJECT("patientIdentifiers",EPID)_" Associated with "_EJPID) D JPIDCLN Q + . I JPID'=EJPID D + . . D SETERROR^VPRJRER(223,"Identifier "_OBJECT("patientIdentifiers",EPID)_" Associated with "_EJPID) + . . D JPIDDIDX(JPID,"JPID;"_JPID) ; Found a collision Error out - I $G(HTTPERR) S EWDERR=1 Q "" + I $G(HTTPERR) S EWDERR=1 QUIT "" ; ; Update the indexes - L +^VPRPTJ("JPID",JPID):$G(^VPRCONFIG("timeout","jpid"),5) E D SETERROR^VPRJRER(502,"Error acquiring lock in ASSOCIATE") Q "" + L +^VPRPTJ("JPID",JPID):$G(^VPRCONFIG("timeout","jpid"),5) E D SETERROR^VPRJRER(502,"Error acquiring lock in ASSOCIATE") QUIT "" ; Add patient to JPID index TSTART S EPID="" F I=1:1 S EPID=$O(OBJECT("patientIdentifiers",EPID)) Q:EPID="" Q:$G(ERR) D . I ($$ISPID(OBJECT("patientIdentifiers",EPID))!$$ISICN(OBJECT("patientIdentifiers",EPID))) D JPIDIDX(JPID,OBJECT("patientIdentifiers",EPID)) . E D SETERROR^VPRJRER(230,"Identifier "_OBJECT("patientIdentifiers",EPID)_" is invalid") S ERR=1 + . D JPIDIDX(JPID,"JPID;"_JPID) TCOMMIT L -^VPRPTJ("JPID",JPID) - Q "/vpr/jpid/"_JPID + ; + QUIT "/vpr/jpid/"_JPID ; DISASSOCIATE(RESULT,ARGS) ;Deassociate a PID/ICN with a JPID N JPID,PID,PIDS @@ -538,8 +542,6 @@ S BODY("jpid")=JPID I '$D(^VPRPTJ("JPID",JPID)) D SETERROR^VPRJRER(224) Q ; Let CLEARPT deal with JPID/PID conversion D CLEARPT^VPRJPS(JPID) - ; Remove last time this patient has been accessed - K ^VPRMETA("JPID",JPID,"lastAccessTime") Q ; JPIDQUERY(ARGS,BODY) ; See if list of PIDS map to the same JPID or aren't known to JDS @@ -573,7 +575,7 @@ S BODY("jpid")=JPID Q "" ; CLEAR() ;Clear all patient identifiers and delete all JPIDs - K ^VPRPTJ("JPID") + K:$D(^VPRPTJ("JPID")) ^VPRPTJ("JPID") Q ; GETPTS(RESULT,ARGS) ;Return a list of patients @@ -583,10 +585,10 @@ S BODY("jpid")=JPID ; Get any filters and parse them into CLAUSES S FILTER=$G(ARGS("filter")) I $L(FILTER) D PARSE^VPRJCF(FILTER,.CLAUSES) Q:$G(HTTPERR) - ; Set OBJECT into ^TMP($J) - S OBJECT=$NA(^TMP($J,"OBJECT")) + ; Set OBJECT into ^||TMP($J) + S OBJECT=$NA(^||TMP($J,"OBJECT")) ; Ensure variables are cleaned out - K @OBJECT + K:$D(@OBJECT) @OBJECT ; Get all patients (or run filter) I '$D(@OBJECT) D . N JPID,PATIENT,PIDS @@ -605,11 +607,11 @@ S BODY("jpid")=JPID . . ; Merge the data (will run only if the filter is true or non-existant) . . M @OBJECT@("items",I)=PATIENT ; Set Result variable to global - S RESULT=$NA(^TMP($J,"RESULT")) - K @RESULT + S RESULT=$NA(^||TMP($J,"RESULT")) + K:$D(@RESULT) @RESULT ; Encode object into JSON return D ENCODE^VPRJSON(OBJECT,RESULT,"ERR") ; From an array to JSON ; Clean up staging variable - K @OBJECT + K:$D(@OBJECT) @OBJECT I $D(ERR) D SETERROR^VPRJRER(202) Q Q diff --git a/VPRJPRN.m b/VPRJPRN.m new file mode 100644 index 0000000..6f2e3c4 --- /dev/null +++ b/VPRJPRN.m @@ -0,0 +1,287 @@ +VPRJPRN ;V4W/DLW -- Wrap Patient CRUD calls to REST endpoints for consumption by jdsClient using cache.node in jds-cache-api + ; + QUIT + ; + ; Get patient demographics from a single site, or from all sites + ; + ; @param {string} IDENTIFIER - Either a PID, or an ICN + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +GETPT(IDENTIFIER,START,LIMIT,STARTID,RETCNTS) ; Called as getPtDemographicsBy{Pid,Icn} in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("icndfn")=$G(IDENTIFIER) + S HTTPREQ("store")="vpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no pid nor icn was passed in + I $G(IDENTIFIER)="" D SETERROR^VPRJRER(211) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D GETPT^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get patient data by index + ; + ; @param {string} PID - Patient identifier + ; @param {string} INDEX - Index name + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [RANGE=""] - A range of keys to limit the items being retrieved by index + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +INDEX(PID,INDEX,TEMPLATE,ORDER,RANGE,BAIL,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getPatientIndexData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("pid")=$G(PID) + S ARGS("indexName")=$G(INDEX) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("range")=$G(RANGE) + S ARGS("bail")=$G(BAIL) + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")="vpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no pid was passed in + I $G(PID)="" D SETERROR^VPRJRER(226) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; bail if no index was passed in + I $G(INDEX)="" D SETERROR^VPRJRER(101) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D INDEX^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get patient data by searching the VPR data store + ; + ; @param {string} PID - Patient identifier + ; @param {string} COLLECTION = Collection name + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +FIND(PID,COLLECTION,TEMPLATE,ORDER,BAIL,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getPatientDomainData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("pid")=$G(PID) + S ARGS("collection")=$G(COLLECTION) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("bail")=$G(BAIL) + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")="vpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no pid was passed in + I $G(PID)="" D SETERROR^VPRJRER(226) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; bail if no collection was passed in + I $G(COLLECTION)="" D SETERROR^VPRJRER(215) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D FIND^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get patient data counts per domain + ; + ; @param {string} PID - Patient identifier + ; @param {string} COUNTNAME - Count name + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +COUNT(PID,COUNTNAME,START,LIMIT,STARTID,RETCNTS) ; Called as getPatientCountData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("pid")=$G(PID) + S ARGS("countName")=$G(COUNTNAME) + S HTTPREQ("store")="vpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no pid was passed in + I $G(PID)="" D SETERROR^VPRJRER(226) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D COUNT^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get all patient data counts per domain + ; + ; @param {string} COUNTNAME + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key +ALLCOUNT(COUNTNAME) ; Called as getAllCountData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,LIMIT,RESULT,RETCNTS,START,STARTID,UUID + ; + ; setup code + S ARGS("countName")=$G(COUNTNAME) + S HTTPREQ("store")="xvpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D ALLCOUNT^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get all patient data by index + ; + ; @param {string} INDEX + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [RANGE=""] - A range of keys to limit the items being retrieved by index + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} [FILTER=""] - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key +ALLINDEX(INDEX,TEMPLATE,ORDER,RANGE,BAIL,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getAllIndexData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("indexName")=$G(INDEX) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("range")=$G(RANGE) + S ARGS("bail")=$G(BAIL) + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")="xvpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D ALLINDEX^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get all patient data by collection by searching the xvpr data store + ; FILTER is not optional + ; + ; @param {string} COLLECTION - Collection name + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [ORDER=""] - Order of the data items in the return array [asc|desc] [ci|cs] + ; @param {string} [BAIL=""] - Similar to limit, but faster, and is unable to calculate totalItems in RETCNTS + ; @param {string} FILTER - A filter expression to apply to the retrieved items + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key +ALLFIND(COLLECTION,TEMPLATE,ORDER,BAIL,FILTER,START,LIMIT,STARTID,RETCNTS) ; Called as getAllDomainData in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("collection")=$G(COLLECTION) + S ARGS("template")=$G(TEMPLATE) + S ARGS("order")=$G(ORDER) + S ARGS("bail")=$G(BAIL) + S ARGS("filter")=$G(FILTER) + S HTTPREQ("store")="xvpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no collection was passed in + I $G(COLLECTION)="" D SETERROR^VPRJRER(215) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D ALLFIND^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get patient data item by PID and UID + ; + ; @param {string} PID - Patient identifier + ; @param {string} UID - Patient data key + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +GETOBJ(PID,UID,TEMPLATE,START,LIMIT,STARTID,RETCNTS) ; Called as getPatientDataByPidAndUid in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("pid")=$G(PID) + S ARGS("uid")=$G(UID) + S ARGS("template")=$G(TEMPLATE) + S HTTPREQ("store")="vpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; bail if no pid was passed in + I $G(PID)="" D SETERROR^VPRJRER(226) QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; call endpoint + D GETOBJ^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; + ; Get patient data item by UID + ; + ; @param {string} UID - Patient data key + ; @param {string} [TEMPLATE=""] - Template to use to format the returned data + ; @param {string} [START=0] - The offset (by count of items) to begin at to add to the return array + ; @param {string} [LIMIT=999999] - Limit of items (by count) to add to the return array + ; @param {string} [STARTID=""] - The first item (by item number or uid) to add to the return array + ; @param {string} [RETCNTS=0] - Return a header with the totalItems and currentItemCount + ; @return {RETURNDATA^VPRJUTLN} RETURN - <0|1>: Error code followed by UUID key to retrieveQueryResult in client-utils.js +GETUID(UID,TEMPLATE,START,LIMIT,STARTID,RETCNTS) ; Called as getPatientDataByUid in jds-client.js + N ARGS,HTTPERR,HTTPREQ,RESULT,UUID + ; + ; setup code + S ARGS("uid")=$G(UID) + S ARGS("template")=$G(TEMPLATE) + S HTTPREQ("store")="xvpr" + D SETUP^VPRJUTLN + ; + S UUID=$$GENUUID^VPRJUTLN + Q:UUID="1:UUID EXCEPTION" UUID + ; + ; call endpoint + D GETUID^VPRJPR(.RESULT,.ARGS) + ; + QUIT $$RETURNDATA^VPRJUTLN(.RESULT,UUID,START,LIMIT,STARTID,RETCNTS) + ; diff --git a/VPRJPS.m b/VPRJPS.m old mode 100755 new mode 100644 index 925b3ae..9c65fdb --- a/VPRJPS.m +++ b/VPRJPS.m @@ -1,5 +1,4 @@ VPRJPS ;SLC/KCM -- Save / Retrieve Patient-Related JSON objects - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; SAVE(JPID,JSON) ; Save a JSON encoded object N UID,COLL,KEY,OBJECT,OLDOBJ,VPRJERR,INDEXER,TLTARY,METASTAMP,PID,SOURCESTAMP,OLDSTAMP,STATUS,SOURCE,DOMAIN,LASTTIME @@ -12,7 +11,7 @@ . M OBJECT=JSON . K JSON . M JSON=SJSON - E D I $D(VPRJERR) D SETERROR^VPRJRER(202) Q "" + E D I $D(VPRJERR) D SETERROR^VPRJRER(202) QUIT "" . K JSON("ewdjs") . ; decode JSON into object and extract required fields . D DECODE^VPRJSON("JSON","OBJECT","VPRJERR") @@ -37,45 +36,60 @@ ; Pre-actions for collections go here ; Next statement is special processing when patient demographics are updated ; (DEMOG is defined if UPDPT has been called already) - I COLL="patient",'$D(DEMOG) S JPID=$$UPDPT^VPRJPR(.OBJECT,JPID) Q:'$L(JPID) "" + I COLL="patient",'$D(DEMOG) S JPID=$$UPDPT^VPRJPR(.OBJECT,JPID) QUIT:'$L(JPID) "" ; ; Get the PID from the object. Always store with the PID of the given object. ; PID is required S PID=$G(OBJECT("pid")) I '$L(PID) D SETERROR^VPRJRER(226) QUIT "" ; Ensure there is a JPID mapping for the PID I '$D(^VPRPTJ("JPID",PID)) D SETERROR^VPRJRER(224) QUIT "" + ; ; Ensure the stampTime exists and is valid - S METASTAMP=$G(OBJECT("stampTime")) I '$$ISSTMPTM^VPRSTMP(METASTAMP) D SETERROR^VPRJRER(221,"Invalid stampTime passed: "_METASTAMP) QUIT "" - ; kill the old indexes and object + S METASTAMP=$G(OBJECT("stampTime")) + I '$$ISSTMPTM^VPRSTMP(METASTAMP) D SETERROR^VPRJRER(221,"Invalid stampTime passed: "_METASTAMP) QUIT "" S OLDSTAMP="" + ; + ; ** Begin Critical Section - data update ** + L +^VPRPT(JPID,PID,UID):$G(^VPRCONFIG("timeout","ptindex"),5) E D SETERROR^VPRJRER(502,"Unable to obtain lock for "_UID) QUIT "" + ; + ; kill the old indexes and object S OLDSTAMP=$O(^VPRPT(JPID,PID,UID,""),-1) ; Get the old object if METASTAMP is equal or greater than OLDSTAMP I OLDSTAMP'="",METASTAMP'0) S JPID=$$JPID4PID^VPRJPR(PID) I JPID="" D SETERROR^VPRJRER(222,"Identifier "_PID) QUIT ; Get the PIDS for a JPID @@ -188,24 +201,26 @@ . S PID=PIDS(ID) . L +^VPRPT(JPID,PID):$G(^VPRCONFIG("timeout","ptdelete"),5) E D SETERROR^VPRJRER(502) QUIT . N HASH ; remove cached queries - . S HASH="" F S HASH=$O(^VPRTMP("PID",PID,HASH)) Q:HASH="" K ^VPRTMP(HASH) - . K ^VPRTMP("PID",PID) + . S HASH="" F S HASH=$O(^VPRTMP("PID",PID,HASH)) Q:HASH="" K:$D(^VPRTMP(HASH)) ^VPRTMP(HASH) + . K:$D(^VPRTMP("PID",PID)) ^VPRTMP("PID",PID) . ; . N KEY ; remove the xref for UID's - . S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" K ^VPRPTJ("KEY",KEY,PID) + . S KEY="" F S KEY=$O(^VPRPT(JPID,PID,KEY)) Q:KEY="" K:$D(^VPRPTJ("KEY",KEY,PID)) ^VPRPTJ("KEY",KEY,PID) . ; - . ;D CLRXIDX^VPRJ2P(PID) ; clear indexes of type xattr + . D CLRXIDX^VPRJ2P(PID) ; clear indexes of type xattr . D CLRCODES^VPRJ2P(PID) ; clear codes in VPRPTX . D CLREVIEW^VPRJ2P(PID) ; clear review dates in VPRPTX . D CLRCOUNT^VPRJ2P(PID) ; decrement the cross patient counts . D DELSS^VPRJPSTATUS(PID) ; Clear Sync Status for PID . D DEL^VPRJOB(JPID) ; Clear Job Status for JPID . ; - . K ^VPRPTI(JPID,PID) ; kill all indexes for the patient - . K ^VPRPT(JPID,PID) ; kill all the data for the patient - . K ^VPRPTJ("JSON",JPID,PID) ; kill original JSON objects for the patient - . K ^VPRPTJ("TEMPLATE",JPID,PID) ; kill the pre-compiled JSON objects for the patient + . K:$D(^VPRPTI(JPID,PID)) ^VPRPTI(JPID,PID) ; kill all indexes for the patient at a particular site + . K:$D(^VPRPT(JPID,PID)) ^VPRPT(JPID,PID) ; kill all the data for the patient at a particular site + . K:$D(^VPRPTJ("JSON",JPID,PID)) ^VPRPTJ("JSON",JPID,PID) ; kill original JSON objects for the patient at a particular site + . K:$D(^VPRPTJ("TEMPLATE",JPID,PID)) ^VPRPTJ("TEMPLATE",JPID,PID) ; kill the pre-compiled JSON objects for the patient at a particular site . ; Remove JPID indexes . D JPIDDIDX^VPRJPR(JPID,PID) . L -^VPRPT(JPID,PID) + ; Remove last time this patient has been accessed + K:$D(^VPRMETA("JPID",JPID,"lastAccessTime")) ^VPRMETA("JPID",JPID,"lastAccessTime") Q diff --git a/VPRJPSTATUS.m b/VPRJPSTATUS.m index 7009fb2..0c0af25 100644 --- a/VPRJPSTATUS.m +++ b/VPRJPSTATUS.m @@ -1,17 +1,16 @@ -VPRJPSTATUS ;KRM/CJE -- Handle Patient Sync Status operations ; 10/20/2015 - ; No entry from top +VPRJPSTATUS ;KRM/CJE,V4W/DLW -- Handle Patient Sync Status operations Q ; SET(ARGS,BODY) ; Store patient metastamps from a source N OBJECT,ERR,JID,JPID,JPID2,ICN,PID,SOURCE,SSOURCE,DOMAIN,DOMAINSTAMP,EVENT,EVENTSTAMP,I,J,K,PREVSTAMP - S OBJECT=$NA(^TMP($J,"metastamp")) - K @OBJECT + S OBJECT=$NA(^||TMP($J,"metastamp")) + K:$D(@OBJECT) @OBJECT D DECODE^VPRJSON("BODY",OBJECT,"ERR") ; Decode JSON to OBJECT array ; Get the source site hash (only one allowed per post) S SOURCE="" S SOURCE=$O(@OBJECT@("sourceMetaStamp",SOURCE)) ; No source found. Quit with error - I SOURCE="""" D SETERROR^VPRJRER(227) K @OBJECT Q "" + I SOURCE="""" D SETERROR^VPRJRER(227) K:$D(@OBJECT) @OBJECT Q "" ; ; Support for all numeric site hashes ; The JSON Encoder/Decoder uses a magic character to tell the JSON @@ -80,7 +79,7 @@ ; Use locking to ensure no one else is modifying the metastamp when a new one is stored ; ; ** Begin Critical Section ** - L +^VPRSTATUS(JPID,PID,SSOURCE):$G(^VPRCONFIG("timeout"),5) E D SETERROR^VPRJRER(502) K @OBJECT Q "" + L +^VPRSTATUS(JPID,PID,SSOURCE):$G(^VPRCONFIG("timeout"),5) E D SETERROR^VPRJRER(502) K:$D(@OBJECT) @OBJECT Q "" ; Set sourcestamp S ^VPRSTATUS(JPID,PID,SSOURCE,"stampTime")=SOURCESTAMP ; foreach domain @@ -106,13 +105,13 @@ L -^VPRSTATUS(JPID,PID,SSOURCE) ; ** End of Critical Section ** ; - K @OBJECT + K:$D(@OBJECT) @OBJECT Q "" ; GET(RETURN,ARGS) ; Return patient sync status based on metastamps N RESULT,DETAILED,JPID,PIDS,ID,RESULT,ERR,FILTER,CLAUSES - S RESULT=$NA(^TMP($J,"RESULT")) - K @RESULT + S RESULT=$NA(^||TMP($J,"RESULT")) + K:$D(@RESULT) @RESULT ; Ensure we don't have any unknown arguments I $$UNKARGS^VPRJCU(.ARGS,"id,detailed,filter") Q ; Set detailed flag if passed @@ -133,19 +132,27 @@ F S ID=$O(PIDS(ID)) Q:ID="" D . D PATIENT(RESULT,PIDS(ID),DETAILED,.CLAUSES) ; - S RETURN=$NA(^TMP($J,"RETURN")) - K @RETURN ; Clear the output global array, avoid subtle bugs + S RETURN=$NA(^||TMP($J,"RETURN")) + K:$D(@RETURN) @RETURN ; Clear the output global array, avoid subtle bugs D ENCODE^VPRJSON(RESULT,RETURN,"ERR") ; From an array to JSON - K @RESULT + K:$D(@RESULT) @RESULT I $D(ERR) D SETERROR^VPRJRER(202) Q Q ; PATIENT(RESULT,PID,DETAILED,CLAUSES,MINIMAL) ; GET Patient Sync Status algorithm N SOURCE,SSOURCE,DOMAINCOMPLETE,BUILD,DOMAIN,DOMAINSTAMP,EVENTSCOMPLETE,EVENT N EVENTSTORED,EVENTSTAMP,COMPLETE,TOTAL,DOMAINARRAY,EVENTARRAY,JPID,DOMAINSTORED + N SOLREVENTSCOMPLETE,SOLREVENTSTORED,SOLRDOMAINSTORED,SOLRDOMAINCOMPLETE,SOLR + N SOLRDOMAIN,SOLREXCEPTIONS,SOLRDOMAINERROR,SYNCDOMAINERROR,SOLRHASERROR,SYNCHASERROR,SYNCEVENTERROR,SOLREVENTERROR ; Ensure Detailed flag exists S DETAILED=$G(DETAILED) S MINIMAL=$G(MINIMAL) + ; Get configuration to determine if SOLR status should be reported + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Get SOLR domains configured to be ignored in the sync status algorithm + S SOLRDOMAIN="",SOLREXCEPTIONS="," + F S SOLRDOMAIN=$O(^VPRCONFIG("sync","status","solr","domainExceptions",SOLRDOMAIN)) Q:SOLRDOMAIN="" D + . S SOLREXCEPTIONS=SOLREXCEPTIONS_SOLRDOMAIN_"," ; Quit if PID doesn't exist I $G(PID)="" Q S SOURCE=$P(PID,";",1) @@ -171,8 +178,8 @@ ; Check to see if we have a metastamp for this source I '$G(^VPRSTATUS(JPID,PID,SOURCE,"stampTime")) Q ; Set BUILD up to use as a target for indirection - S BUILD=$NA(^TMP($J,"RESULT","BUILD")) - K @BUILD + S BUILD=$NA(^||TMP($J,"RESULT","BUILD")) + K:$D(@BUILD) @BUILD ; ; This may be blank if no ICN is on file, if it is blank only primary site data is on file S:'MINIMAL @BUILD@("icn")=$$ICN4JPID^VPRJPR(JPID) @@ -191,7 +198,7 @@ ; F S DOMAIN=$O(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN)) Q:DOMAIN="" D . ; skip non domain subscripts - . I DOMAIN="stampTime"!(DOMAIN="syncCompleteAsOf") Q + . I DOMAIN="stampTime"!(DOMAIN="syncCompleteAsOf")!(DOMAIN="solrSyncCompleteAsOf") Q . ; . ; Set the domain stampTime . ; A is the first character after numerics so we can run the $O backwards @@ -201,18 +208,25 @@ . ; Flag if all domains are complete . ; If a domainstamp doesn't exist domain can never be complete . I DOMAINSTAMP="" S DOMAINCOMPLETE=0 - . E I $G(DOMAINCOMPLETE)'=0 S DOMAINCOMPLETE=1 - . S DOMAINSTORED=0 + . E I $G(DOMAINCOMPLETE)'=0 S DOMAINCOMPLETE=1 + . ; Solr flag if all domains are complete + . I SOLR D + . . I DOMAINSTAMP="" S SOLRDOMAINCOMPLETE=0 + . . E I $G(SOLRDOMAINCOMPLETE)'=0 S SOLRDOMAINCOMPLETE=1 + . S (SOLRDOMAINSTORED,DOMAINSTORED,SOLRDOMAINERROR,SYNCDOMAINERROR)=0 . ; . ; eventMetaStamp object . ; All events begin with urn - . S EVENTSCOMPLETE=1 . S EVENT="urn" + . ; Complete flags + . S (EVENTSCOMPLETE,SOLREVENTSCOMPLETE)=1 + . ; Total number of eventStamp . S COMPLETE=0 + . ; . F TOTAL=1:1 S EVENT=$O(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,EVENT)) Q:EVENT="" D . . I EVENT="stampTime" Q . . ; Flag if all events are complete within a domain - . . S EVENTSTORED=0 + . . S (EVENTSTORED,SOLREVENTSTORED,SOLREVENTERROR,SYNCEVENTERROR)=0 . . ; . . ; Get the event stampTime . . ; A is the first character after numerics so we can run the $O backwards @@ -222,6 +236,17 @@ . . ; Get the stored flag . . I $G(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,EVENT,EVENTSTAMP,"stored")) S EVENTSTORED=1 . . E S EVENTSCOMPLETE=0 + . . ; Get the SOLR stored flag + . . I SOLR D + . . . I $G(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,EVENT,EVENTSTAMP,"solrStored")) S SOLREVENTSTORED=1 + . . . E I SOLREXCEPTIONS'[(","_DOMAIN_",") S SOLREVENTSCOMPLETE=0 + . . ; + . . ; Get the SOLR error flag + . . I $G(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,EVENT,EVENTSTAMP,"solrError")) D + . . . S (SOLREVENTERROR,SOLRDOMAINERROR,SOLRHASERROR)=1 + . . ; Get the Sync error flag + . . I $G(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,EVENT,EVENTSTAMP,"syncError")) D + . . . S (SYNCEVENTERROR,SYNCDOMAINERROR,SYNCHASERROR)=1 . . ; . . I EVENTSTORED S COMPLETE=COMPLETE+1 . . ; @@ -232,6 +257,9 @@ . . S EVENTARRAY("uid")=EVENT,EVENTARRAY("event")=EVENT . . S EVENTARRAY("stampTime")=EVENTSTAMP . . I EVENTSTORED S EVENTARRAY("stored")="true" + . . I SOLR,SOLREVENTSTORED S EVENTARRAY("solrStored")="true" + . . I SOLREVENTERROR S EVENTARRAY("solrError")="true" + . . I SYNCEVENTERROR S EVENTARRAY("syncError")="true" . . ; All clauses are wrapped in an implicit AND . . I DETAILED,$D(CLAUSES),'$$EVALAND^VPRJGQF(.CLAUSES,$NA(EVENTARRAY)) Q . . ; @@ -239,14 +267,25 @@ . . I DETAILED S @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"eventMetaStamp",EVENT,"stampTime")=EVENTSTAMP . . ; . . I DETAILED,EVENTSTORED S @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"eventMetaStamp",EVENT,"stored")="true" + . . I SOLR,DETAILED,SOLREVENTSTORED S @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"eventMetaStamp",EVENT,"solrStored")="true" + . . I DETAILED,SOLREVENTERROR S @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"eventMetaStamp",EVENT,"solrError")="true" + . . I DETAILED,SYNCEVENTERROR S @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"eventMetaStamp",EVENT,"syncError")="true" . ; . ; Set the flags to control syncCompleted for the domain and inProgress/completedStamp for the entire site - . I EVENTSCOMPLETE,DOMAINSTAMP'="" D - . . ; domain is complete - . . S DOMAINSTORED=1 - . E D - . . ; set entire site inProgress - domain is not complete - . . S DOMAINCOMPLETE=0 + . ; Is the domain complete, if so set DOMAINSTORED=1 + . I EVENTSCOMPLETE,DOMAINSTAMP'="" S DOMAINSTORED=1 + . ; domain isn't complete, set DOMAINCOMPLETE=0 + . E S DOMAINCOMPLETE=0 + . ; Set the flag to control solrSyncCompleted for the domain + . I SOLR D + . . I SOLREVENTSCOMPLETE,DOMAINSTAMP'="" S SOLRDOMAINSTORED=1 + . . E S SOLRDOMAINCOMPLETE=0 + . . ; Need to test and maybe set SOLRDOMAINSTORED again so that SOLRDOMAINCOMPLETE can still be set to 0 for metaStamp roll-up + . . I SOLREXCEPTIONS[(","_DOMAIN_";") S SOLRDOMAINSTORED=1 + . ; + . ; Set mutual exclusion flags for sync/solr errors. They can never be complete if there is an error. + . I SOLRDOMAINERROR S (SOLRDOMAINSTORED,SOLRDOMAINCOMPLETE)=0 + . I SYNCDOMAINERROR S (DOMAINSTORED,DOMAINCOMPLETE)=0 . ; . ; TOTAL will be one extra from the loop before it quits at end of data . S TOTAL=TOTAL-1 @@ -257,11 +296,21 @@ . S DOMAINARRAY("stampTime")=DOMAINSTAMP . S DOMAINARRAY("storedCount")=COMPLETE . I EVENTSCOMPLETE S DOMAINARRAY("syncCompleted")="true" + . I SOLR,SOLREVENTSCOMPLETE S DOMAINARRAY("solrSyncCompleted")="true" + . I SOLREVENTERROR S DOMAINARRAY("hasSolrError")="true" + . I SYNCEVENTERROR S DOMAINARRAY("hasSyncError")="true" + . ; . ; All clauses are wrapped in an implicit AND . I 'DETAILED,$D(CLAUSES),'$$EVALAND^VPRJGQF(.CLAUSES,$NA(DOMAINARRAY)) Q . ; - . ; If we pass the filter add the syncCompleted for the domain + . ; If we pass the filter and the syncCompleted for the domain . S:'MINIMAL @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"syncCompleted")=$S(DOMAINSTORED:"true",1:"false") + . ; If we pass the filter and the solrSyncCompleted for the domain + . S:SOLR&('MINIMAL) @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"solrSyncCompleted")=$S(SOLRDOMAINSTORED:"true",1:"false") + . ; If we pass the filter and there are solr errors for the domain + . S:'MINIMAL @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"hasSolrError")=$S(SOLRDOMAINERROR:"true",1:"false") + . ; If we pass the filter and there are sync errors for the domain + . S:'MINIMAL @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"hasSyncError")=$S(SYNCDOMAINERROR:"true",1:"false") . ; . ; If domainstamp is null set the domain stampTime to the latest event stamp . I DOMAINSTAMP="",EVENTSTAMP>DOMAINSTAMP D @@ -273,7 +322,20 @@ . ; Add event counts to output . S:'MINIMAL @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"eventCount")=TOTAL . S:'MINIMAL @BUILD@("sourceMetaStamp",SSOURCE,"domainMetaStamp",DOMAIN,"storedCount")=COMPLETE - ; Set the complete flag if all of the domains were complete + ; + ; Set the solr complete flag if all of the domains are complete + I SOLR,$G(SOLRDOMAINCOMPLETE) D + . S @BUILD@("sourceMetaStamp",SSOURCE,"solrSyncCompleted")="true" + . S ^VPRSTATUS(JPID,PID,SOURCE,"solrSyncCompleteAsOf")=$$CURRTIME^VPRJRUT + . S:'MINIMAL @BUILD@("sourceMetaStamp",SSOURCE,"solrSyncCompleteAsOf")=$G(^VPRSTATUS(JPID,PID,SOURCE,"solrSyncCompleteAsOf")) + E S:(SOLR)&($G(^VPRSTATUS(JPID,PID,SOURCE,"solrSyncCompleteAsOf"))'="")&('MINIMAL) @BUILD@("sourceMetaStamp",SSOURCE,"solrSyncCompleteAsOf")=$G(^VPRSTATUS(JPID,PID,SOURCE,"solrSyncCompleteAsOf")) + ; + ; Set the solr error flag if any event is in error + S @BUILD@("sourceMetaStamp",SSOURCE,"hasSolrError")=$S($G(SOLRHASERROR):"true",1:"false") + ; Set the sync error flag if any event is in error + S @BUILD@("sourceMetaStamp",SSOURCE,"hasSyncError")=$S($G(SYNCHASERROR):"true",1:"false") + ; + ; Set the complete flag if all of the domains are complete I $G(DOMAINCOMPLETE) D . S @BUILD@("sourceMetaStamp",SSOURCE,"syncCompleted")="true" . S ^VPRSTATUS(JPID,PID,SOURCE,"syncCompleteAsOf")=$$CURRTIME^VPRJRUT @@ -282,55 +344,72 @@ E D . S:$G(^VPRSTATUS(JPID,PID,SOURCE,"syncCompleteAsOf"))'=""&('MINIMAL) @BUILD@("sourceMetaStamp",SSOURCE,"syncCompleteAsOf")=$G(^VPRSTATUS(JPID,PID,SOURCE,"syncCompleteAsOf")) . M @RESULT@("inProgress")=@BUILD - K @BUILD + K:$D(@BUILD) @BUILD Q ; CLEAR(RESULT,ARGS) ; Delete all sync status data - K ^VPRSTATUS + K:$D(^VPRSTATUS) ^VPRSTATUS Q + ; DELSS(PID) ; Delete a patient's sync status N JPID S JPID=$$JPID4PID^VPRJPR(PID) I JPID="" D SETERROR^VPRJRER(224,"Unable to acquire JPID for PID: "_PID) Q ; - K ^VPRSTATUS(JPID,PID) + K:$D(^VPRSTATUS(JPID,PID)) ^VPRSTATUS(JPID,PID) Q + ; DELSITE(SITE) ; Delete a site's sync status N PID,JPID S JPID="" F S JPID=$O(^VPRPT(JPID)) Q:JPID="" D . S PID=SITE . F S PID=$O(^VPRPT(JPID,PID)) Q:PID=""!($P(PID,";")'=SITE) D - . . K ^VPRSTATUS(JPID,PID) + . . K:$D(^VPRSTATUS(JPID,PID)) ^VPRSTATUS(JPID,PID) Q -STORERECORD(RESULT,BODY) - ; Testing endpoint - N OBJECT,ERR,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,JPID + ; +STORERECORD(ARGS,BODY) + ; Set flags to indicate records are stored or in error. + ; supports type="jds" only for testing purposes - not to be used in regular operations + ; type="solr","solrError","syncError" is supported for regular operations + N OBJECT,ERR,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,JPID,TYPE D DECODE^VPRJSON("BODY","OBJECT","ERR") - S PID=$G(OBJECT("pid")) - S SOURCE=$G(OBJECT("source")) S UID=$G(OBJECT("uid")) - S DOMAIN=$G(OBJECT("domain")) + S PID=$G(ARGS("pid")) + S SOURCE=$P(PID,";",1) + S DOMAIN=$P(UID,":",3) S EVENTSTAMP=$G(OBJECT("eventStamp")) + S TYPE=$G(OBJECT("type")) S JPID=$$JPID4PID^VPRJPR(PID) - I JPID="" D SETERROR^VPRJRER(224,"Unable to acquire JPID for PID: "_PID) Q - I $D(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP)) S ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"stored")="1" - Q "" + I JPID="" D SETERROR^VPRJRER(224,"Unable to acquire JPID for PID: "_PID) Q "" + I (DOMAIN="")!(UID="")!(EVENTSTAMP="")!($P(UID,":",6)="") D SETERROR^VPRJRER(210,"Required fields are missing from the UID or eventStamp") Q "" + I (TYPE="")!(TYPE="jds") D + . S ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"stored")=1 + . K:$D(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"syncError")) ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"syncError") + E I (TYPE="solr") D + . S ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"solrStored")=1 + . K:$D(^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"solrError")) ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"solrError") + E I (TYPE="solrError") S ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"solrError")=1 + E I (TYPE="syncError") S ^VPRSTATUS(JPID,PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"syncError")=1 + Q "/vpr/"_PID_"/"_UID ; COMBINED(RETURN,ARGS) ; Return patient sync status with job status ; NOTE: if only id associations are stored the the timestamp and stampTimes are empty strings instead ; of numeric - N RESULT,DETAILED,JPID,PIDS,ID,RESULT,ERR,FILTER,CLAUSES,ALLCOMPLETE,SITES,SITELIST - S RESULT=$NA(^TMP($J,"RESULT","syncStatus")) - K ^TMP($J,"RESULT") + N RESULT,DETAILED,JPID,PIDS,ID,RESULT,ERR,FILTER,CLAUSES,ALLCOMPLETE,SITES,SITELIST,DEBUG + S RESULT=$NA(^||TMP($J,"RESULT","syncStatus")) + K:$D(^||TMP($J,"RESULT")) ^||TMP($J,"RESULT") ; Ensure we don't have any unknown arguments - I $$UNKARGS^VPRJCU(.ARGS,"icnpidjpid,sites") Q + I $$UNKARGS^VPRJCU(.ARGS,"icnpidjpid,sites,debug") Q ; Set sites list S SITELIST=0 S SITES=$G(ARGS("sites")) + S DEBUG=$G(ARGS("debug")) I $L(SITES) S SITELIST=1 ; If we don't have a site list set the global syncStatus to true - S:'SITELIST ^TMP($J,"RESULT","return","syncCompleted")="true" + S:'SITELIST ^||TMP($J,"RESULT","return","syncCompleted")="true" + ; If solr status is enabled and we don't have a site list set the global solrSyncStatus to true + S:$G(^VPRCONFIG("sync","status","solr"))&('SITELIST) ^||TMP($J,"RESULT","return","solrSyncCompleted")="true" ; ; Get the JPID based on passed patient identifier S JPID="" @@ -344,22 +423,16 @@ S ESR=$$GETJOBBYINDEX(.ESRJOB,JPID,"enterprise-sync-request") ; ; Job debugging - ;N INCR S INCR=$I(^KTMP($J)) - ;M ^KTMP($J,INCR,"RESULT","JOBS","ESR")=ESRJOB - ;M ^KTMP($J,INCR,"RESULT","PIDS")=PIDS + M:DEBUG ^||TMP($J,"RESULT","debug","JOBS","ESR")=ESRJOB + M:DEBUG ^||TMP($J,"RESULT","debug","PIDS")=PIDS ; ; We always want to report the last time an enterprise-sync-request was created for the patient - S ^TMP($J,"RESULT","return","latestEnterpriseSyncRequestTimestamp")=$G(ESRJOB("timestamp")) + S ^||TMP($J,"RESULT","return","latestEnterpriseSyncRequestTimestamp")=$G(ESRJOB("timestamp")) ; ; Global enterprise-sync-request rules ; If enterprise-sync-request is in error the site can never be complete ; Set the hasError flag and set syncComplete=false - I $G(ESRJOB("status"))="error" D BLDRESULT($G(PIDS(1)),"false",$G(ESRJOB("timestamp")),1) G BLDRETURN - ; - ; If we have a started enterprise-sync-request, but no patient identifiers the sync isn't complete - ; We are guaranteed to have 2 results in the PIDS array in most cases (the JPID and the identifier - ; used to begin the ESR job) so we check the third one if the ESRJOB is in started status. - I ($G(ESRJOB("status"))="started")&($G(PIDS(3))="") D BLDRESULT($G(PIDS(1)),"false",$G(ESRJOB("timestamp"))) G BLDRETURN + I $G(ESRJOB("status"))="error" D BLDRESULT($G(PIDS(1)),"false",$G(ESRJOB("timestamp")),"job") G BLDRETURN ; ; Loop through identifiers for patient S ID="" @@ -373,6 +446,7 @@ . ; . ; Always get the patient meta-stamp . D PATIENT(RESULT,PIDS(ID),"",.CLAUSES,1) + . M:DEBUG ^||TMP($J,"RESULT","return","debug","syncStatus")=^||TMP($J,"RESULT","syncStatus") . ; . ; VistA Primary Site and VistA/HDR Pub/Sub Checks . ; These checks are combined as there is no way to tell via PID which is which @@ -392,54 +466,54 @@ . . ; . . ; Overwrite latestJobTimestamp to include other jobs that aren't data jobs . . I $G(VSRJOB("timestamp"))>$G(VDJOBS("latestTimestamp")) S VDJOBS("latestTimestamp")=VSRJOB("timestamp") - . . I $G(ESRJOB("timestamp"))>$G(VDJOBS("latestTimestamp")) S VDJOBS("latestTimestamp")=ESRJOB("timestamp") . . ; vistahdr . . I $G(VHSRJOB("timestamp"))>$G(VHDJOBS("latestTimestamp")) S VHDJOBS("latestTimestamp")=VHSRJOB("timestamp") - . . I $G(ESRJOB("timestamp"))>$G(VHDJOBS("latestTimestamp")) S VHDJOBS("latestTimestamp")=ESRJOB("timestamp") . . ; . . ; Determine if Jobs are in error . . I $G(VSRJOB("status"))="error" S VDJOBS("hasError")=1 - . . I $G(VDJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp"),1) Q + . . I $G(VDJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp"),"job") Q . . ; vistahdr . . I $G(VHSRJOB("status"))="error" S VHDJOBS("hasError")=1 - . . I $G(VHDJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp"),1) Q + . . I $G(VHDJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp"),"job") Q . . ; . . ; Save jobs off to global for debugging - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"ESR")=ESRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"VSR")=VSRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"VDJOBS")=VDJOBS - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"VHSR")=VHSRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"VHDJOBS")=VHDJOBS + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"ESR")=ESRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VSR")=VSRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VDJOBS")=VDJOBS + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VHSR")=VHSRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VHDJOBS")=VHDJOBS . . ; . . ; 1. If vista-{SiteHash}-subscribe-request OR vista-{SiteHash}-data-{domain}-poller jobs are OPEN or ERROR: syncComplete = false - . . I (($G(VSRJOB("status"))'="completed")!('VDJOBS("allJobsComplete")))&(('VHSR)&('VHDJOBS("numberOfJobs"))) S ^TMP($J,"RESULT","RULES",SITE)="VISTA RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp")) Q + . . I (($G(VSRJOB("status"))'="completed")!('VDJOBS("allJobsComplete")))&(('VHSR)&('VHDJOBS("numberOfJobs"))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VISTA RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp")) Q . . ; . . ; 2. If vista-{SiteHash}-subscribe-request AND vista-{SiteHash}-data-{domain}-poller are COMPLETED syncComplete = meta-stamp status + . . ; NOTE: This works because we never complete jobs until we open the next job in the chain. This is enforced by VX-Sync. . . I ($G(VSRJOB("status"))="completed")&(VDJOBS("allJobsComplete")) D Q . . . ; setup SSITE to deal with fully numeric site hashes . . . I SITE=+SITE S SSITE=""""_SITE_"" . . . E S SSITE=SITE - . . . I $D(^TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SSITE)) S ^TMP($J,"RESULT","RULES")="VISTA RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp")) - . . . E I $D(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SSITE)) S ^TMP($J,"RESULT","RULES",SITE)="VISTA RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VDJOBS("latestTimestamp")) - . . . E I '$D(^TMP($J,"RESULT","syncStatus")) S ALLCOMPLETE=0 + . . . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SSITE)) S:DEBUG ^||TMP($J,"RESULT","return","RULES")="VISTA RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp")) + . . . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SSITE)) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VISTA RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VDJOBS("latestTimestamp")) + . . . E I '$D(^||TMP($J,"RESULT","syncStatus")) S ALLCOMPLETE=0 . . ; . . ; 3. If vista-{SiteHash}-subscribe-request OR vista-{SiteHash}-data-{domain}-poller don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false - . . I (('VSR)!('VDJOBS("numberOfJobs")))&('VHSR)&('VHDJOBS("numberOfJobs"))&(($G(ESRJOB("status"))="open")) S ^TMP($J,"RESULT","RULES",SITE)="VISTA RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp")) Q + . . I (('VSR)!('VDJOBS("numberOfJobs")))&('VHSR)&('VHDJOBS("numberOfJobs"))&(($G(ESRJOB("status"))'="completed")) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VISTA RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VDJOBS("latestTimestamp")) Q . . ; . . ; VistA HDR Pub/Sub . . ; 1. If vistahdr-{SiteHash}-subscribe-request OR vistahdr-{SiteHash}-data-{domain}-poller jobs are OPEN or ERROR: syncComplete = false - . . I (($G(VHSRJOB("status"))'="completed")!('VHDJOBS("allJobsComplete"))) S ^TMP($J,"RESULT","RULES",SITE)="VISTAHDR RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp")) Q + . . I (($G(VHSRJOB("status"))'="completed")!('VHDJOBS("allJobsComplete"))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VISTAHDR RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp")) Q . . ; . . ; 2. If vistahdr-{SiteHash}-subscribe-request OR vistahdr-{SiteHash}-data-{domain}-poller are COMPLETE: syncComplete = meta-stamp status + . . ; NOTE: This works because we never complete jobs until we open the next job in the chain. This is enforced by VX-Sync. . . I ($G(VHSRJOB("status"))="completed")&(VHDJOBS("allJobsComplete")) D Q . . . ; setup SSITE to deal with fully numeric site hashes . . . I SITE=+SITE S SSITE=""""_SITE_"" . . . E S SSITE=SITE - . . . I $D(^TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SSITE)) S ^TMP($J,"RESULT","RULES")="VISTAHDR RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp")) - . . . E I $D(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SSITE)) S ^TMP($J,"RESULT","RULES",SITE)="VISTAHDR RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VHDJOBS("latestTimestamp")) + . . . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SSITE)) S:DEBUG ^||TMP($J,"RESULT","return","RULES")="VISTAHDR RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp")) + . . . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SSITE)) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VISTAHDR RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VHDJOBS("latestTimestamp")) . . ; . . ; 3. If vistahdr-{SiteHash}-subscribe-request OR vistahdr-{SiteHash}-data-{domain}-poller don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false - . . I (('VHSR)!('VHDJOBS("numberOfJobs")))&('VSR)&('VDJOBS("numberOfJobs"))&(($G(ESRJOB("status"))="open")) S ^TMP($J,"RESULT","RULES",SITE)="VISTAHDR RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp")) Q + . . I (('VHSR)!('VHDJOBS("numberOfJobs")))&('VSR)&('VDJOBS("numberOfJobs"))&(($G(ESRJOB("status"))'="completed")) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VISTAHDR RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VHDJOBS("latestTimestamp")) Q . ; . E I SITE="HDR" D . . ; HDR Req/Res @@ -453,29 +527,29 @@ . . ; Overwrite latestJobTimestamp to include other jobs that aren't data jobs . . I $G(HSRJOB("timestamp"))>$G(HDJOBS("latestTimestamp")) S HDJOBS("latestTimestamp")=HSRJOB("timestamp") . . I $G(HXJOBS("latestTimestamp"))>$G(HDJOBS("latestTimestamp")) S HDJOBS("latestTimestamp")=HXJOBS("latestTimestamp") - . . I $G(ESRJOB("timestamp"))>$G(HDJOBS("latestTimestamp")) S HDJOBS("latestTimestamp")=ESRJOB("timestamp") . . ; . . ; Determine if Jobs are in error . . I $G(HSRJOB("status"))="error" S HDJOBS("hasError")=1 . . I $G(HXJOBS("hasError")) S HDJOBS("hasError")=1 - . . I $G(HDJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp"),1) Q + . . I $G(HDJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp"),"job") Q . . ; . . ; Save jobs off to global for debugging - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"ESR")=ESRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"HSR")=HSRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"HSDR")=HDJOBS - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"HX")=HXJOBS + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"ESR")=ESRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"HSR")=HSRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"HSDR")=HDJOBS + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"HX")=HXJOBS . . ; . . ; 1. If hdr-subscribe-request OR hdr-sync-{domain}-request OR hdr-xform-{domain}-vpr jobs are OPEN or ERROR: syncComplete = false - . . I ($G(HSRJOB("status"))'="completed")!('HDJOBS("allJobsComplete"))!((HXJOBS("numberOfJobs"))&('HXJOBS("allJobsComplete"))) S ^TMP($J,"RESULT","RULES",SITE)="HDR RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp")) Q + . . I ($G(HSRJOB("status"))'="completed")!('HDJOBS("allJobsComplete"))!((HXJOBS("numberOfJobs"))&('HXJOBS("allJobsComplete"))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="HDR RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp")) Q . . ; - . . ; 2. If enterprise-sync-request AND hdr-subscribe-request AND hdr-sync-{domain}-request AND hdr-xform-{domain}-vpr are COMPLETE: syncComplete = meta-stamp status - . . I ($G(ESRJOB("status"))="completed")&($G(HSRJOB("status"))="completed")&(HDJOBS("allJobsComplete"))&(('HXJOBS("numberOfJobs"))!(HXJOBS("allJobsComplete"))) D Q - . . . I $D(^TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S ^TMP($J,"RESULT","RULES",SITE)="HDR RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp")) - . . . E I $D(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S ^TMP($J,"RESULT","RULES",SITE)="HDR RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",HDJOBS("latestTimestamp")) + . . ; 2. If hdr-subscribe-request AND hdr-sync-{domain}-request AND hdr-xform-{domain}-vpr are COMPLETE: syncComplete = meta-stamp status + . . ; NOTE: This works because we never complete jobs until we open the next job in the chain. This is enforced by VX-Sync. + . . I ($G(HSRJOB("status"))="completed")&(HDJOBS("allJobsComplete"))&(('HXJOBS("numberOfJobs"))!(HXJOBS("allJobsComplete"))) D Q + . . . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="HDR RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp")) + . . . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="HDR RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",HDJOBS("latestTimestamp")) . . ; . . ; 3. If hdr-subscribe-request AND hdr-sync-{domain}-request AND hdr-xform-{domain}-vpr don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false - . . I ('HSR)&('HDJOBS("numberOfJobs"))&('HXJOBS("numberOfJobs"))&(($G(ESRJOB("status"))="open")) S ^TMP($J,"RESULT","RULES",SITE)="HDR RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp")) Q + . . I ('HSR)&('HDJOBS("numberOfJobs"))&('HXJOBS("numberOfJobs"))&(($G(ESRJOB("status"))'="completed")) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="HDR RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",HDJOBS("latestTimestamp")) Q . ; . E I SITE="DOD" D . . ; DOD Req/Res @@ -495,7 +569,6 @@ . . I $G(JPDTJOB("timestamp"))>$G(JJOBS("latestTimestamp")) S JJOBS("latestTimestamp")=JPDTJOB("timestamp") . . I $G(JXJOBS("latestTimestamp"))>$G(JJOBS("latestTimestamp")) S JJOBS("latestTimestamp")=JXJOBS("latestTimestamp") . . I $G(JCDCJOB("timestamp"))>$G(JJOBS("latestTimestamp")) S JJOBS("latestTimestamp")=JCDCJOB("timestamp") - . . I $G(ESRJOB("timestamp"))>$G(JJOBS("latestTimestamp")) S JJOBS("latestTimestamp")=ESRJOB("timestamp") . . ; . . ; Determine if Jobs are in error . . I $G(JSRJOB("status"))="error" S JJOBS("hasError")=1 @@ -503,104 +576,186 @@ . . I $G(JPDTJOB("status"))="error" S JJOBS("hasError")=1 . . I $G(JCDCJOB("status"))="error" S JJOBS("hasError")=1 . . I $G(JXJOBS("hasError")) S JJOBS("hasError")=1 - . . I $G(JJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp"),1) Q + . . I $G(JJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp"),"job") Q . . ; . . ; Save jobs off to global for debugging - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"ESR")=ESRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"JS")=JSRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"JJOBS")=JJOBS - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"JDR")=JDRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"JPDT")=JPDTJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"JX")=JXJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"JCDC")=JCDCJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"ESR")=ESRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"JSR")=JSRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"JJOBS")=JJOBS + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"JDR")=JDRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"JPDT")=JPDTJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"JX")=JXJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"JCDC")=JCDCJOB . . ; . . ; 1. If jmeadows-sync-request OR jmeadows-sync-{domain}-request OR jmeadows-document-retrieval OR jmeadows-pdf-document-transform OR jmeadows-xform-{domain}-vpr . . ; OR jmeadows-cda-document-conversion jobs are OPEN or ERROR: syncComplete = false - . . I ($G(JSRJOB("status"))'="completed")!('JJOBS("allJobsComplete"))!((JDR)&($G(JDRJOB("status"))'="completed"))!((JPDT)&($G(JPDTJOB("status"))'="completed"))!((JXJOBS("numberOfJobs"))&('JXJOBS("allJobsComplete")))!((JCDC)&($G(JCDCJOB("status"))'="completed")) S ^TMP($J,"RESULT","RULES",SITE)="DOD RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp")) Q + . . I ($G(JSRJOB("status"))'="completed")!('JJOBS("allJobsComplete"))!((JDR)&($G(JDRJOB("status"))'="completed"))!((JPDT)&($G(JPDTJOB("status"))'="completed"))!((JXJOBS("numberOfJobs"))&('JXJOBS("allJobsComplete")))!((JCDC)&($G(JCDCJOB("status"))'="completed")) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="DOD RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp")) Q . . ; - . . ; 2. If enterprise-sync-request AND jmeadows-sync-request AND jmeadows-sync-{domain}-request AND jmeadows-document-retrieval AND jmeadows-pdf-document-transform + . . ; 2. If jmeadows-sync-request AND jmeadows-sync-{domain}-request AND jmeadows-document-retrieval AND jmeadows-pdf-document-transform . . ; AND jmeadows-xform-{domain}-vpr AND jmeadows-cda-document-conversion are COMPLETE: syncComplete = meta-stamp status - . . I ($G(ESRJOB("status"))="completed")&($G(JSRJOB("status"))="completed")&(JJOBS("allJobsComplete"))&(('JDR)!($G(JDRJOB("status"))="completed"))&(('JPDT)!($G(JPDTJOB("status"))="completed"))&(('JXJOBS("numberOfJobs"))!(JXJOBS("allJobsComplete")))&(('JCDC)!($G(JCDCJOB("status"))="completed")) D Q - . . . I $D(^TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S ^TMP($J,"RESULT","RULES",SITE)="DOD RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp")) - . . . E I $D(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S ^TMP($J,"RESULT","RULES",SITE)="DOD RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",JJOBS("latestTimestamp")) + . . ; NOTE: This works because we never complete jobs until we open the next job in the chain. This is enforced by VX-Sync. + . . I ($G(JSRJOB("status"))="completed")&(JJOBS("allJobsComplete"))&(('JDR)!($G(JDRJOB("status"))="completed"))&(('JPDT)!($G(JPDTJOB("status"))="completed"))&(('JXJOBS("numberOfJobs"))!(JXJOBS("allJobsComplete")))&(('JCDC)!($G(JCDCJOB("status"))="completed")) D Q + . . . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="DOD RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp")) + . . . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="DOD RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",JJOBS("latestTimestamp")) . . ; . . ; 3. If jmeadows-sync-request AND jmeadows-sync-{domain}-request AND jmeadows-document-retrieval AND jmeadows-pdf-document-transform . . ; AND jmeadows-xform-{domain}-vpr AND jmeadows-cda-document-conversion don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false - . . I ('JSR)&('JJOBS("numberOfJobs"))&('JXJOBS("numberOfJobs"))&('JDR)&('JPDT)&('JCDC)&(($G(ESRJOB("status"))="open")) S ^TMP($J,"RESULT","RULES",SITE)="DOD RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp")) Q + . . I ('JSR)&('JJOBS("numberOfJobs"))&('JXJOBS("numberOfJobs"))&('JDR)&('JPDT)&('JCDC)&(($G(ESRJOB("status"))'="completed")) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="DOD RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",JJOBS("latestTimestamp")) Q . ; . E I SITE="VLER" D - . . ; VLER Req/Res + . . ; VLER Req/Res, DAS/FHIR . . ; . . ; Get jobs - . . N VSR,VSRJOB,VXV,VXVJOB,VJOBS + . . N VSR,VSRJOB,VXV,VXVJOB,VDSR,VDSRJOB,VDSUR,VDSURJOB,VDDR,VDDRJOB,VDXV,VDXVJOB,VJOBS + . . ; Req/Res . . S VSR=$$GETJOBBYINDEX(.VSRJOB,JPID,"vler-sync-request") . . S VXV=$$GETJOBBYINDEX(.VXVJOB,JPID,"vler-xform-vpr") - . . S VJOBS("latestTimestamp")=$S($G(VSRJOB("timestamp"))>$G(VXVJOB("timestamp")):VSRJOB("timestamp"),1:$G(VSRJOB("timestamp"))) - . . I $G(ESRJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=ESRJOB("timestamp") + . . ; DAS/FHIR + . . S VDSR=$$GETJOBBYINDEX(.VDSRJOB,JPID,"vler-das-sync-request") + . . S VDSUR=$$GETJOBBYINDEX(.VDSURJOB,JPID,"vler-das-subscribe-request") + . . S VDDR=$$GETJOBBYINDEX(.VDDRJOB,JPID,"vler-das-doc-retrieve") + . . S VDXV=$$GETJOBBYINDEX(.VDXVJOB,JPID,"vler-das-xform-vpr") + . . ; + . . ; Overwrite latestJobTimestamp to include other jobs that aren't data jobs + . . S VJOBS("latestTimestamp")="" + . . I $G(VSRJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=VSRJOB("timestamp") + . . I $G(VXVJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=VXVJOB("timestamp") + . . I $G(VDSRJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=VDSRJOB("timestamp") + . . I $G(VDSURJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=VDSURJOB("timestamp") + . . I $G(VDDRJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=VDDRJOB("timestamp") + . . I $G(VDXVJOB("timestamp"))>$G(VJOBS("latestTimestamp")) S VJOBS("latestTimestamp")=VDXVJOB("timestamp") . . ; . . ; Determine if Jobs are in error . . I $G(VSRJOB("status"))="error" S VJOBS("hasError")=1 . . I $G(VXVJOB("status"))="error" S VJOBS("hasError")=1 - . . I $G(VJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp"),1) Q + . . I $G(VDSRJOB("status"))="error" S VJOBS("hasError")=1 + . . I $G(VDSURJOB("status"))="error" S VJOBS("hasError")=1 + . . I $G(VDDRJOB("status"))="error" S VJOBS("hasError")=1 + . . I $G(VDXVJOB("status"))="error" S VJOBS("hasError")=1 + . . I $G(VJOBS("hasError")) D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp"),"job") Q . . ; . . ; Save jobs off to global for debugging - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"ESR")=ESRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"VSR")=VSRJOB - . . ;M ^KTMP($J,INCR,"RESULT","JOBS",SITE,"VXV")=VXVJOB - . . ; - . . ; 1. If vler-sync-request OR vler-xform-vpr jobs are OPEN or ERROR: syncComplete = false - . . I ($G(VSRJOB("status"))'="completed")!((VXV)&($G(VXVJOB("status"))'="completed")) S ^TMP($J,"RESULT","RULES",SITE)="VLER RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) Q - . . ; - . . ; 2. If enterprise-sync-request AND vler-sync-request AND vler-xform-vpr are COMPLETE: syncComplete = meta-stamp status - . . I ($G(ESRJOB("status"))="completed")&($G(VSRJOB("status"))="completed")&(('VXV)!($G(VXVJOB("status"))="completed")) D Q - . . . I $D(^TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S ^TMP($J,"RESULT","RULES",SITE)="VLER RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) - . . . E I $D(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S ^TMP($J,"RESULT","RULES",SITE)="VLER RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VJOBS("latestTimestamp")) - . . ; - . . ; 3. If vler-sync-request AND vler-xform-vpr don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false - . . I ('VSR)&('VXV)&(($G(ESRJOB("status"))="open")) S ^TMP($J,"RESULT","RULES",SITE)="VLER RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) Q + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"ESR")=ESRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VSR")=VSRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VXV")=VXVJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VDSR")=VDSRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VDSUR")=VDSURJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VDDR")=VDDRJOB + . . M:DEBUG ^||TMP($J,"RESULT","return","debug","jobs",SITE,"VDXV")=VDXVJOB + . . ; + . . ; 1. If vler-sync-request OR vler-xform-vpr jobs are OPEN or ERROR (aka not completed): syncComplete = false + . . I (((VSR)&($G(VSRJOB("status"))'="completed"))!((VXV)&($G(VXVJOB("status"))'="completed"))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",$G(VJOBS("latestTimestamp"))) Q + . . ; + . . ; 2. If ((vler-sync-request AND vler-xform-vpr) are COMPLETE: syncComplete = meta-stamp status + . . ; NOTE: This works because we never complete jobs until we open the next job in the chain. This is enforced by VX-Sync. + . . I ((($G(VSRJOB("status"))="completed")&(('VXV)!($G(VXVJOB("status"))="completed")))) D Q + . . . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) + . . . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VJOBS("latestTimestamp")) + . . ; + . . ; 3. If (vler-sync-request AND vler-xform-vpr) don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false + . . ; NOTE: If ESR is in error this rule should never be executed. ESR errors are dealt with early and meant to fail fast. + . . ; NOTE: This covers both VLER and VLER DAS in some cases + . . I ('VSR)&('VXV)&('VDSR)&('VDSUR)&('VDDR)&('VDXV)&($G(ESRJOB("status"))'="completed") S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) Q + . . ; + . . ; VLER DAS + . . ; 1. If vler-das-sync-request OR vler-das-subscribe-request OR vler-das-doc-retrieve jobs are OPEN or ERROR (aka not completed): syncComplete = false + . . I ((('VSR)&($G(VDSRJOB("status"))'="completed"))!(($G(VDSURJOB("status"))'="completed"))!(($G(VDDRJOB("status"))'="completed"))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER DAS RULE 1 FALSE" D BLDRESULT(PIDS(ID),"false",$G(VJOBS("latestTimestamp"))) Q + . . ; + . . ; 2. If (vler-das-sync-request AND vler-das-subscribe-request AND vler-das-doc-retrieve)) are COMPLETE: syncComplete = meta-stamp status + . . ; NOTE: This works because we never complete jobs until we open the next job in the chain. This is enforced by VX-Sync. + . . I (($G(VDSRJOB("status"))="completed"))&(($G(VDSURJOB("status"))="completed"))&(($G(VDDRJOB("status"))="completed")) D Q + . . . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER DAS RULE 2 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) + . . . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",$P(PIDS(ID),";",1))) S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER DAS RULE 2 TRUE" D BLDRESULT(PIDS(ID),"true",VJOBS("latestTimestamp")) + . . ; + . . ; 3. If (vler-das-sync-request OR vler-das-subscribe-request OR vler-das-doc-retrive) don't exist AND enterprise-sync-request is OPEN or ERROR: syncComplete = false + . . ; NOTE: If ESR is in error this rule should never be executed. ESR errors are dealt with early and meant to fail fast. + . . I (('VDSR)!('VDSUR)!('VDDR))&($G(ESRJOB("status"))'="completed") S:DEBUG ^||TMP($J,"RESULT","return","RULES",SITE)="VLER DAS RULE 3 FALSE" D BLDRESULT(PIDS(ID),"false",VJOBS("latestTimestamp")) Q + . ; + . ; Check for sync or solr errors regardless of whether the sync is in progress or completed + . I $D(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SITE)) D + . . ; Determine if there are any sync errors + . . I $G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SITE,"hasSyncError"),"false")="true" D + . . . D BLDRESULT(PIDS(ID),"false",$G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SITE,"stampTime")),"sync") + . . ; + . . ; Determine if there are any solr errors + . . I $G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SITE,"hasSolrError"),"false")="true" D + . . . D BLDRESULT(PIDS(ID),"",$G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SITE,"stampTime")),"solr") + . E I $D(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SITE)) D + . . ; Determine if there are any sync errors + . . I $G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SITE,"hasSyncError"),"false")="true" D + . . . D BLDRESULT(PIDS(ID),"false",$G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SITE,"stampTime")),"sync") + . . ; + . . ; Determine if there are any solr errors + . . I $G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SITE,"hasSolrError"),"false")="true" D + . . . D BLDRESULT(PIDS(ID),"",$G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SITE,"stampTime")),"solr") ; BLDRETURN ; Build Return - S ^TMP($J,"RESULT","return","icn")=$$ICN4JPID^VPRJPR(JPID) + S ^||TMP($J,"RESULT","return","icn")=$$ICN4JPID^VPRJPR(JPID) + ; + ; Check to make sure we have a site to return. If we don't return a sync status that is false + I $D(^||TMP($J,"RESULT","return","sites"))=0 D BLDRESULT($G(PIDS(1)),"false",$G(ESRJOB("timestamp"))) ; - S RETURN=$NA(^TMP($J,"RETURN")) - K @RETURN ; Clear the output global array, avoid subtle bugs - D ENCODE^VPRJSON($NA(^TMP($J,"RESULT","return")),RETURN,"ERR") ; From an array to JSON - K @RESULT + S RETURN=$NA(^||TMP($J,"RETURN")) + K:$D(@RETURN) @RETURN ; Clear the output global array, avoid subtle bugs + D ENCODE^VPRJSON($NA(^||TMP($J,"RESULT","return")),RETURN,"ERR") ; From an array to JSON + K:$D(@RESULT) @RESULT I $D(ERR) D SETERROR^VPRJRER(202) Q Q ; BLDRESULT(PID,STATUS,TIMESTAMP,ERROR) - N SOURCE + N SOURCE,SOLRSTATUS S SOURCE=$P(PID,";",1) I SOURCE=+SOURCE S SOURCE=""""_SOURCE_"" + ; + ; NOTE: ERROR is being used as both a flag to indicate that there was an error, + ; and it also contains a string representing what type of error it is. If ERROR + ; is undefined (because nothing was passed as the fourth argument to this call), + ; or it happens to contain an "", then that means there is no error, which can + ; happen because this call is called by many parts of the simple sync status end + ; point (combinedstat), in order to build up the correct response object. + ; + ; Set Site & Global hasError and hasSolrError flags for jobs, sync, and solr errors + I $G(ERROR)="job"!($G(ERROR)="sync") D + . I $$ISPID^VPRJPR(PID) S ^||TMP($J,"RESULT","return","sites",SOURCE,"hasError")="true" + . S ^||TMP($J,"RESULT","return","hasError")="true" + E I $G(ERROR)="solr" D + . I $$ISPID^VPRJPR(PID) S ^||TMP($J,"RESULT","return","sites",SOURCE,"hasSolrError")="true" + . S ^||TMP($J,"RESULT","return","hasSolrError")="true" + . ; Also need to set solrSyncCompleted to false + . I $G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"stampTime")) D + . . S ^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"solrSyncCompleted")="false" + . E I $G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SOURCE,"stampTime")) D + . . S ^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SOURCE,"solrSyncCompleted")="false" + ; I $$ISPID^VPRJPR(PID) D - . S ^TMP($J,"RESULT","return","sites",SOURCE,"pid")=PID - . S ^TMP($J,"RESULT","return","sites",SOURCE,"syncCompleted")=STATUS + . S ^||TMP($J,"RESULT","return","sites",SOURCE,"pid")=PID + . S:$G(STATUS)'="" ^||TMP($J,"RESULT","return","sites",SOURCE,"syncCompleted")=STATUS . ; - . ; Set Site sourceStampTime (either from inProgress or completedStamp) - . I $G(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"stampTime")) D - . . S ^TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime")=$G(^TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"stampTime")) + . ; Set Site sourceStampTime (either from inProgress or completedStamp) and solr sync status + . I $G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"stampTime")) D + . . S ^||TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime")=$G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"stampTime")) + . . ; if solrSyncComplted doesn't exist the answer is false (implemented as the $G default) + . . S:$G(^VPRCONFIG("sync","status","solr")) (SOLRSTATUS,^||TMP($J,"RESULT","return","sites",SOURCE,"solrSyncCompleted"))=$G(^||TMP($J,"RESULT","syncStatus","completedStamp","sourceMetaStamp",SOURCE,"solrSyncCompleted"),"false") . E D - . . S ^TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime")=$G(^TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SOURCE,"stampTime")) + . . S ^||TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime")=$G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SOURCE,"stampTime")) + . . ; if solrSyncComplted doesn't exist the answer is false (implemented as the $G default) + . . S:$G(^VPRCONFIG("sync","status","solr")) (SOLRSTATUS,^||TMP($J,"RESULT","return","sites",SOURCE,"solrSyncCompleted"))=$G(^||TMP($J,"RESULT","syncStatus","inProgress","sourceMetaStamp",SOURCE,"solrSyncCompleted"),"false") . ; . ; Set Site latestJobTimestamp - . S ^TMP($J,"RESULT","return","sites",SOURCE,"latestJobTimestamp")=TIMESTAMP - ; - ; Set Site & Global hasError flag - I $G(ERROR) D - . I $$ISPID^VPRJPR(PID) S ^TMP($J,"RESULT","return","sites",SOURCE,"hasError")="true" - . S ^TMP($J,"RESULT","return","hasError")="true" + . S ^||TMP($J,"RESULT","return","sites",SOURCE,"latestJobTimestamp")=TIMESTAMP ; ; Set Global syncStatus - I 'SITELIST&(STATUS="false") S ^TMP($J,"RESULT","return","syncCompleted")="false" + I 'SITELIST&(STATUS="false") S ^||TMP($J,"RESULT","return","syncCompleted")="false" + ; Set Global solrSyncStatus + I ($G(^VPRCONFIG("sync","status","solr")))&('SITELIST)&($G(SOLRSTATUS,"false")="false") S ^||TMP($J,"RESULT","return","solrSyncCompleted")="false" ; ; Set Global latestSourceStampTime - I 'SITELIST&($G(^TMP($J,"RESULT","return","latestSourceStampTime"))<$G(^TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime"))) D - . S ^TMP($J,"RESULT","return","latestSourceStampTime")=$G(^TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime")) + I 'SITELIST&($G(^||TMP($J,"RESULT","return","latestSourceStampTime"))<$G(^||TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime"))) D + . S ^||TMP($J,"RESULT","return","latestSourceStampTime")=$G(^||TMP($J,"RESULT","return","sites",SOURCE,"sourceStampTime")) ; ; Set Global latestJobTimestamp - I 'SITELIST&($G(^TMP($J,"RESULT","return","latestJobTimestamp"))0:$H,1:"") Q CLEAR ; clear the logs - K ^VPRHTTP("log") + K:$D(^VPRHTTP("log")) ^VPRHTTP("log") Q LOG() ; return the current logging level Q $G(^VPRHTTP(0,"logging"),0) ; -PORT() ; return the HTTP port number - Q $G(^VPRHTTP(0,"port"),9080) +PORT() ; return the HTTP port numbers + N NUM,PORTS + S NUM="",PORTS="" + F S NUM=$O(^VPRHTTP(NUM)) Q:NUM'=+NUM I $D(^VPRHTTP(NUM,"port"))#2 S PORTS=PORTS_" "_^VPRHTTP(NUM,"port") + S $E(PORTS)="" + QUIT PORTS ; STATUS() ; Return status of the HTTP listener ;Simple Exchange (happy path) @@ -62,17 +98,19 @@ ; ;{"status":"running"} ; - I $E($G(^VPRHTTP(0,"listener")),1,4)="stop" Q ^VPRHTTP(0,"listener") - ; - N HTTPLOG,HTTPREQ,PORT,X - S HTTPLOG=0,PORT=$G(^VPRHTTP(0,"port"),9080) - O "|TCP|2":("127.0.0.1":PORT:"CT"):2 E Q "not responding" - U "|TCP|2" - W "GET /ping HTTP/1.1"_$C(10,13)_"Host: JDSlocalhost"_$C(10,13,10,13),! - F S X=$$RDCRLF^VPRJREQ() Q:'$L(X) D ADDHEAD^VPRJREQ(X) - U "|TCP|2":(::"S") - I $G(HTTPREQ("header","content-length"))>0 D RDLEN^VPRJREQ(HTTPREQ("header","content-length"),2) - C "|TCP|2" - S X=$P($G(HTTPREQ("body",1)),"""",4) - I '$L(X) Q "unknown" - Q X + N HTTPLOG,HTTPREQ,PORT,X,NUM,STATUS + S (NUM,X)="",STATUS="" + F S NUM=$O(^VPRHTTP(NUM)) Q:NUM'=+NUM I $D(^VPRHTTP(NUM,"listener"))#2 D + . S HTTPLOG=0,PORT=^VPRHTTP(NUM,"port") + . O "|TCP|2":("127.0.0.1":PORT:"CT"):2 E S STATUS=STATUS_"Port "_PORT_" not responding, " Q + . U "|TCP|2" + . W "GET /ping HTTP/1.1"_$C(10,13)_"Host: JDSlocalhost"_$C(10,13,10,13),! + . F S X=$$RDCRLF^VPRJREQ() Q:'$L(X) D ADDHEAD^VPRJREQ(X) + . U "|TCP|2":(::"S") + . I $G(HTTPREQ("header","content-length"))>0 D RDLEN^VPRJREQ(HTTPREQ("header","content-length"),2) + . C "|TCP|2" + . S X=$P($G(HTTPREQ("body",1)),"""",4) + . S STATUS=STATUS_"Port "_PORT_" "_X_", " + . I '$L(X) S STATUS=STATUS_"Port "_PORT_" unknown, " + S STATUS=$RE(STATUS),$E(STATUS,1,2)="",STATUS=$RE(STATUS) + QUIT STATUS diff --git a/VPRJREQ.m b/VPRJREQ.m index f11cbc5..b7229b9 100644 --- a/VPRJREQ.m +++ b/VPRJREQ.m @@ -1,83 +1,33 @@ -VPRJREQ ;SLC/KCM -- Listen for HTTP requests;2017-04-25 4:38 PM - ;;1.0;JSON DATA STORE;;Sep 01, 2012 +VPRJREQ ;SLC/KCM -- Listen for HTTP requests ; ; Listener Process --------------------------------------- ; START(TCPPORT) ; set up listening for connections - Q:$G(^VPRHTTP(0,"updating")) ; don't allow starting during upgrade + Q:$G(^VPRHTTP(0,"updating")) ; don't allow starting during upgrade ; - S TCPPORT=$G(TCPPORT,9080) + N FLG + S ^VPRHTTP(TCPPORT,"listener")="running" ; - ; Setup for different M implementations/Virtual machines - N OS S OS=$S(+$SY=47:"GT.M",+$SY=50:"MV1",1:"CACHE") ; Get Mumps Virtual Machine - I OS="GT.M" S @("$ZINTERRUPT=""I $$JOBEXAM^VPRJREQ($ZPOSITION)""") ; for GT.M, set interrupt. - ; - ; Device ID - I OS="CACHE" S TCPIO="|TCP|"_TCPPORT - I OS="GT.M" S TCPIO="SCK$"_TCPPORT - ; - ; Open Code - I OS="CACHE" O TCPIO:(:TCPPORT:"ACT"::::1000):15 E U 0 W !,"error cannot open port "_TCPPORT Q - I OS="GT.M" O TCPIO:(LISTEN=TCPPORT_":TCP":delim=$C(13,10):attach="server"):15:"socket" E U 0 W !,"error cannot open port "_TCPPORT Q - ; - ; Now we are really really listening. - S ^VPRHTTP(0,"listener")="running" - ; - ; This is the same for GT.M and Cache + S TCPPORT=+$G(TCPPORT) + S TCPIO="|TCP|"_TCPPORT + O TCPIO:(/ACCEPT=1:/CRLF=1:/TMODE=1:/PORT=TCPPORT:/NOXY=1:/CONNECTIONS=1000:/IBUFSIZE=$G(^VPRCONFIG("HTTP","inputBuffer"),1048576):/OBUFSIZE=$G(^VPRCONFIG("HTTP","outputBuffer"),1048576)):15 E U 0 W !,"error" QUIT U TCPIO - ; - I OS="GT.M" W /LISTEN(5) ; Listen 5 deep - sets $KEY to "LISTENING|socket_handle|portnumber" - N PARSOCK S PARSOCK=$P($KEY,"|",2) ; Parent socket - N CHILDSOCK ; That will be set below; Child socket - ; LOOP ; wait for connection, spawn process to handle it - I $E(^VPRHTTP(0,"listener"),1,4)="stop" C TCPIO S ^VPRHTTP(0,"listener")="stopped" Q + S FLG=0 + I $D(^VPRHTTP(TCPPORT,"listener"))#2,$E(^VPRHTTP(TCPPORT,"listener"),1,4)="stop" D + . C TCPIO + . S ^VPRHTTP(TCPPORT,"listener")="stopped" + . S FLG=1 + I FLG QUIT D CHRON ; - ; ---- CACHE CODE ---- - I OS="CACHE" D G LOOP - . R *X:10 - . E QUIT ; Loop back again when listening and nobody on the line - . J CHILD:(:4:TCPIO:TCPIO):10 ; Send off the device to another job for input and output. - . I $ZA\8196#2=1 W *-2 ; job failed to clear bit - ; ---- END CACHE CODE ---- - ; - ; ----- GT.M CODE ---- - ; In GT.M $KEY is "CONNECT|socket_handle|portnumber" then "READ|socket_handle|portnumber" - ; N GTMDONE S GTMDONE=0 ; To tell us if we should loop waiting or process HTTP requests ; don't need this anymore - ; I OS="GT.M" D G LOOP:'GTMDONE,CHILD:GTMDONE - I OS="GT.M" D G LOOP - . ; - . ; Wait until we have a connection (inifinte wait). - . ; Stop if the listener asked us to stop. - . FOR W /WAIT(10) Q:$KEY]"" Q:($E(^VPRHTTP(0,"listener"),1,4)="stop") - . ; - . ; We have to stop! When we quit, we go to loop, and we exit at LOOP+1 - . I $E(^VPRHTTP(0,"listener"),1,4)="stop" QUIT - . ; - . ; At connection, job off the new child socket to be served away. - . ; I $P($KEY,"|")="CONNECT" QUIT ; before 6.1 - . I $P($KEY,"|")="CONNECT" D ; >=6.1 - . . S CHILDSOCK=$P($KEY,"|",2) - . . U TCPIO:(detach=CHILDSOCK) - . . N Q S Q="""" - . . N ARG S ARG=Q_"SOCKET:"_CHILDSOCK_Q - . . N J S J="CHILD:(input="_ARG_":output="_ARG_")" - . . J @J - . ; - . ; GT.M before 6.1: - . ; Use the incoming socket; close the server, and restart it and goto CHILD - . ; USE TCPIO:(SOCKET=$P($KEY,"|",2)) - . ; CLOSE TCPIO:(SOCKET="server") - . ; JOB START^VPRJREQ(TCPPORT):(IN="/dev/null":OUT="/dev/null":ERR="/dev/null"):5 - . ; SET GTMDONE=1 ; Will goto CHILD at the DO exist up above - . ; ---- END GT.M CODE ---- - ; - QUIT - ; -JOBEXAM(%ZPOS) ; Interrupt framework for GT.M. - ZSHOW "*":^VPRHTTP("processlog",+$H,$P($H,",",2),$J) - QUIT 1 + R *X:10 I '$T G LOOP + ; + J CHILD:(:4:TCPIO:TCPIO):10 + I $ZA\8196#2=1 W *-2 ; job failed to clear bit + ; + G LOOP + ; ; CHRON ; handle events related to passage of time ; TODO: start job every n seconds to handle logging check, review xrefs, etc. @@ -92,13 +42,6 @@ S S=S-$P(TS,",",2),S=S+(D*86400) Q S ; -GTMLNX ;From Linux xinetd script; $P is the main stream - S ^VPRHTTP(0,"listener")="starting" - S @("$ZINTERRUPT=""I $$JOBEXAM^VPRJREQ($ZPOSITION)""") - X "U $P:(nowrap:nodelimiter:ioerror=""ETSOCK"")" - S %="",@("%=$ZTRNLNM(""REMOTE_HOST"")") S:$L(%) IO("IP")=% - G CHILD - ; ; Child Handling Process --------------------------------- ; ; The following variables exist during the course of the request @@ -118,26 +61,24 @@ ; HTTPERR non-zero if there is an error state ; CHILD ; handle HTTP requests on this connection - N TCP S TCP=$GET(TCPIO,$PRINCIPAL) ; TCP Device - N OS S OS=$S(+$SY=47:"GT.M",+$SY=50:"MV1",1:"CACHE") ; Get Mumps Virtual Machine - S HTTPLOG("DT")=+$H + S HTTPLOG("DT")=+$H ; same timestamp used for log throughout session N $ET S $ET="G ETSOCK^VPRJREQ" ; NEXT ; begin next request K HTTPREQ,HTTPRSP,HTTPERR - K ^TMP($J),^TMP("HTTPERR",$J) ; TODO: change the namespace for the error global + K:$D(^||TMP($J)) ^||TMP($J) + K:$D(^||TMP("HTTPERR",$J)) ^||TMP("HTTPERR",$J) S HTTPLOG=$S($D(HTTPLOG("this")):HTTPLOG("this"),1:$G(^VPRHTTP(0,"logging"),0)) I HTTPLOG=2,'$D(HTTPLOG("path")) S HTTPLOG("path")=$G(^VPRHTTP(0,"logging","path")) ; WAIT ; wait for request on this connection - I $E($G(^VPRHTTP(0,"listener")),1,4)="stop" C TCP Q - X:OS="CACHE" "U TCP:(::""CT"")" ;VEN/SMH - Cache Only line; Terminators are $C(10,13) - X:OS="GT.M" "U TCP:(delim=$C(13,10))" ; VEN/SMH - GT.M Delimiters + U $P:(::"CT") R TCPX:10 I '$T G WAIT I '$L(TCPX) G WAIT ; ; -- got a request and have the first line - D INCRLOG ; set unique request id + ; only increment the logger if we have logging enabled + D:HTTPLOG INCRLOG ; set unique request id I HTTPLOG>3 D LOGRAW(TCPX) S HTTPREQ("line1")=TCPX S HTTPREQ("method")=$P(TCPX," ") @@ -151,8 +92,7 @@ S HTTPREQ("query")=$P($P(TCPX," ",2),"?",2,999) F S TCPX=$$RDCRLF() Q:'$L(TCPX) D ADDHEAD(TCPX) ; ; -- decide how to read body, if any - X:OS="CACHE" "U TCP:(::""S"")" ; Stream mode - X:OS="GT.M" "U TCP:(nodelim)" ; VEN/SMH - GT.M Delimiters + U $P:(::"S") ; TODO: handle chunked input of body I $$LOW^VPRJRUT($G(HTTPREQ("header","transfer-encoding")))="chunked" D RDCHNKS ; handle regular input of body @@ -166,16 +106,16 @@ S HTTPREQ("query")=$P($P(TCPX," ",2),"?",2,999) ; TODO: restore HTTPLOG if necessary ; ; -- write out the response (error if HTTPERR>0) - X:OS="CACHE" "U TCP:(::""S"")" ; Stream mode - X:OS="GT.M" "U TCP:(nodelim)" ; VEN/SMH - GT.M Delimiters + U $P:(::"S") I $G(HTTPERR) D RSPERROR^VPRJRSP ; switch to error response D SENDATA^VPRJRSP I HTTPLOG D LOGGING ; ; -- exit on Connection: Close - I $$LOW^VPRJRUT($G(HTTPREQ("header","connection")))="close" D Q - . K ^TMP($J),^TMP("HTTPERR",$J) - . C TCP + I $$LOW^VPRJRUT($G(HTTPREQ("header","connection")))="close" D QUIT + . K:$D(^||TMP($J)) ^||TMP($J) + . K:$D(^||TMP("HTTPERR",$J)) ^||TMP("HTTPERR",$J) + . C $P ; ; -- otherwise get ready for the next request G NEXT @@ -221,7 +161,7 @@ S HTTPREQ("query")=$P($P(TCPX," ",2),"?",2,999) ; ETSOCK ; error trap when handling socket (i.e., client closes connection) D LOGERR - C TCP H 2 + C $P H 2 HALT ; exit because connection has been closed ; ETCODE ; error trap when calling out to routines @@ -239,10 +179,11 @@ S HTTPREQ("query")=$P($P(TCPX," ",2),"?",2,999) S $ETRAP="Q:$ESTACK&$QUIT 0 Q:$ESTACK S $ECODE="""" G NEXT" Q ETBAIL ; error trap of error traps - U TCP + U $P W "HTTP/1.1 500 Internal Server Error",$C(13,10),$C(13,10),! - C TCP H 1 - K ^TMP($J),^TMP("HTTPERR",$J) + C $P H 1 + K:$D(^||TMP($J)) ^||TMP($J) + K:$D(^||TMP("HTTPERR",$J)) ^||TMP("HTTPERR",$J) HALT ; exit because we can't recover ; INCRLOG ; get unique log id for each request @@ -270,7 +211,7 @@ S HTTPLOG("ID")=ID I $L($G(HTTPLOG("name"))) D . S ^VPRHTTP("log",DT,$J,ID,"name")=HTTPLOG("name") . S ^VPRHTTP("log","names",HTTPLOG("name"),DT,$J,ID)="" ; xref by name - I $G(HTTPERR) M ^VPRHTTP("log",DT,$J,ID,"error","http")=^TMP("HTTPERR",$J) + I $G(HTTPERR) M ^VPRHTTP("log",DT,$J,ID,"error","http")=^||TMP("HTTPERR",$J) M ^VPRHTTP("log",DT,$J,ID,"response","body")=HTTPRSP M ^VPRHTTP("log",DT,$J,ID,"response","request")=HTTPREQ Q @@ -283,6 +224,8 @@ S HTTPLOG("ID")=ID S ^VPRHTTP("log",DT,$J,ID,"raw",LN,"ZB")=$A($ZB) Q LOGERR ; log error information + ; Always increment the log id for errors + D INCRLOG N %D,%I S %D=HTTPLOG("DT"),%I=HTTPLOG("ID") S ^VPRHTTP("log",%D,$J,%I,"error")=$ZERROR_" ($ECODE:"_$ECODE_")" diff --git a/VPRJRER.m b/VPRJRER.m old mode 100755 new mode 100644 index 4ceb8e8..26bcefa --- a/VPRJRER.m +++ b/VPRJRER.m @@ -1,7 +1,7 @@ VPRJRER ;SLC/KCM -- Error Recording ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; -SETERROR(ERRCODE,MESSAGE) ; set error info into ^TMP("HTTPERR",$J) +SETERROR(ERRCODE,MESSAGE) ; set error info into ^||TMP("HTTPERR",$J) ; causes HTTPERR system variable to be set ; ERRCODE: query errors are 100-199, update errors are 200-299, M errors are 500 ; MESSAGE: additional explanatory material @@ -21,6 +21,7 @@ I ERRCODE=111 S ERRNAME="Unrecognized parameter" I ERRCODE=112 S ERRNAME="Filter required" I ERRCODE=113 S ERRNAME="No reverse field name" + I ERRCODE=114 S HTTPERR=413,TOPMSG="Request entity too large",ERRNAME="Parameter length limit exceeded" ; update errors (200-299) I ERRCODE=201 S ERRNAME="Unknown collection" ; unused? I ERRCODE=202 S ERRNAME="Unable to decode JSON" @@ -73,6 +74,7 @@ ; Generic Data Store Error codes I ERRCODE=270 S HTTPERR=400,ERRNAME="Error generating index metadata" I ERRCODE=271 S HTTPERR=400,ERRNAME="Duplicate index found" + I ERRCODE=272 S HTTPERR=500,ERRNAME="Record already locked" ; HTTP errors I ERRCODE=400 S ERRNAME="Bad Request" I ERRCODE=404 S ERRNAME="Not Found" @@ -93,7 +95,7 @@ . . S RSET=##class(%ResultSet).%New("%SYS.LockQuery:List") . . ; Execute the query to get all locks (includes remote systems from ECP) . . D RSET.Execute("") - . . WHILE (RSET.Next()){S LCNT=$G(LCNT)+1 S ^TMP("HTTPERR",$J,1,"error","locks",LCNT)=RSET.Data("LockString")} + . . WHILE (RSET.Next()){S LCNT=$G(LCNT)+1 S ^||TMP("HTTPERR",$J,1,"error","locks",LCNT)=RSET.Data("LockString")} . I LOCKS'="" D . . S ERRNAME=$G(ERRNAME)_" Lock space available "_$P(LOCKS,",",1) . . S ERRNAME=$G(ERRNAME)_" Lock space usable "_$P(LOCKS,",",2) @@ -103,11 +105,11 @@ ; I ERRCODE>500 S HTTPERR=500,TOPMSG="Internal Server Error" ; M Server Error I ERRCODE<500,ERRCODE>400 S HTTPERR=ERRCODE,TOPMSG=ERRNAME ; Other HTTP Errors - S NEXTERR=$G(^TMP("HTTPERR",$J,0),0)+1,^TMP("HTTPERR",$J,0)=NEXTERR - S ^TMP("HTTPERR",$J,1,"error","code")=HTTPERR - S ^TMP("HTTPERR",$J,1,"error","message")=TOPMSG - S ^TMP("HTTPERR",$J,1,"error","request")=$G(HTTPREQ("method"))_" "_$G(HTTPREQ("path"))_" "_$G(HTTPREQ("query")) - S ^TMP("HTTPERR",$J,1,"error","errors",NEXTERR,"reason")=ERRCODE - S ^TMP("HTTPERR",$J,1,"error","errors",NEXTERR,"message")=ERRNAME - I $L($G(MESSAGE)) S ^TMP("HTTPERR",$J,1,"error","errors",NEXTERR,"domain")=MESSAGE + S NEXTERR=$G(^||TMP("HTTPERR",$J,0),0)+1,^||TMP("HTTPERR",$J,0)=NEXTERR + S ^||TMP("HTTPERR",$J,1,"error","code")=HTTPERR + S ^||TMP("HTTPERR",$J,1,"error","message")=TOPMSG + S ^||TMP("HTTPERR",$J,1,"error","request")=$G(HTTPREQ("method"))_" "_$G(HTTPREQ("path"))_" "_$G(HTTPREQ("query")) + S ^||TMP("HTTPERR",$J,1,"error","errors",NEXTERR,"reason")=ERRCODE + S ^||TMP("HTTPERR",$J,1,"error","errors",NEXTERR,"message")=ERRNAME + I $L($G(MESSAGE)) S ^||TMP("HTTPERR",$J,1,"error","errors",NEXTERR,"domain")=MESSAGE Q diff --git a/VPRJRSP.m b/VPRJRSP.m old mode 100755 new mode 100644 index 46fca16..821cbf0 --- a/VPRJRSP.m +++ b/VPRJRSP.m @@ -1,19 +1,28 @@ VPRJRSP ;SLC/KCM -- Handle HTTP Response - ;;1.0;JSON DATA STORE;;Sep 01, 2012 - ; ; -- prepare and send RESPONSE ; RESPOND ; find entry point to handle request and call it ; expects HTTPREQ, HTTPRSP is used to return the response ; ; TODO: check cache of HEAD requests first and return that if there? - K ^TMP($J) - N ROUTINE,LOCATION,HTTPARGS,HTTPBODY,LOWPATH + K:$D(^||TMP($J)) ^||TMP($J) + N ROUTINE,LOCATION,HTTPARGS,HTTPBODY,LOWPATH,QARGS,BAIL + D QSPLIT(.QARGS) I $G(HTTPERR) QUIT ; need to see if query=true before calling MATCH + ; support for POST queries, so that we can treat them like regular GET requests + I HTTPREQ("method")="POST",$G(QARGS("query"))="true" S HTTPREQ("method")="GET" D MATCH(.ROUTINE,.HTTPARGS) I $G(HTTPERR) QUIT - D QSPLIT(.HTTPARGS) I $G(HTTPERR) QUIT - S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) + M HTTPARGS=QARGS K QARGS ; MATCH clears HTTPARGS, so we need to merge in the query arguments from QSPLIT S LOWPATH=$$LOW^VPRJRUT(HTTPREQ("path")) S HTTPREQ("store")=$S($E(LOWPATH,2,9)="vpr/all/":"xvpr",$E(LOWPATH,2,4)="vpr":"vpr",$L($P(LOWPATH,"/",2)):$P(LOWPATH,"/",2),1:"data") + ; support for POST queries, merge the POST body in to HTTPARGS, so GET endpoints work + ; get out if handling a POST query results in a JSON decoder error, or a max string error + I $G(HTTPARGS("query"))="true" D QUIT:BAIL + . K HTTPARGS("query") ; the GET endpoints would fail if this node existed + . D DECODE^VPRJSON("HTTPREQ(""body"")","HTTPARGS","VPRJERR") + . I $G(VPRJERR) D SETERROR^VPRJRER(202) S BAIL=1 Q + . S BAIL=$$QCONCAT(.HTTPARGS) + S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) + S HTTPREQ("returncounts")=$G(HTTPARGS("returncounts"),"false") ; treat PUT and POST the same for now (we always replace objects when updating) I "PUT,POST,PATCH"[HTTPREQ("method") D QUIT . N BODY @@ -22,13 +31,15 @@ S HTTPREQ("store")=$S($E(LOWPATH,2,9)="vpr/all/":"xvpr",$E(LOWPATH,2,4)="vpr":"v . I $L(LOCATION) S HTTPREQ("location")=$S($D(HTTPREQ("header","host")):"http://"_HTTPREQ("header","host")_LOCATION,1:LOCATION) ; otherwise treat as GET D @(ROUTINE_"(.HTTPRSP,.HTTPARGS)") - Q + QUIT + ; QSPLIT(QUERY) ; parses and decodes query fragment into array ; expects HTTPREQ to contain "query" node ; .QUERY will contain query parameters as subscripts: QUERY("name")=value - N I,X,NAME,VALUE - F I=1:1:$L(HTTPREQ("query"),"&") D - . S X=$$URLDEC^VPRJRUT($P(HTTPREQ("query"),"&",I)) + N I,X,NAME,VALUE,QSTRING + S QSTRING=$$URLDEC^VPRJRUT(HTTPREQ("query")) + F I=1:1:$L(QSTRING,"&") D + . S X=$P(QSTRING,"&",I) . S NAME=$P(X,"="),VALUE=$P(X,"=",2,999) . I $L(NAME) S QUERY($$LOW^VPRJRUT(NAME))=VALUE Q @@ -58,18 +69,38 @@ S HTTPREQ("store")=$S($E(LOWPATH,2,9)="vpr/all/":"xvpr",$E(LOWPATH,2,4)="vpr":"v I PATHOK,ROUTINE="" D SETERROR^VPRJRER(405,"Method Not Allowed") QUIT I ROUTINE="" D SETERROR^VPRJRER(404,"Not Found") QUIT Q + ; +QCONCAT(ARGS) ; flatten any extension nodes in ARGS, caused by long query arguments having to go through the JSON decoder + N BAIL,COUNT,LINE,MAX,NODE,TEST + S NODE="",(COUNT,BAIL)=0 + ; max string length limit (in Cache) is 3641144, but ARGS is concatenated with other strings later on, so need lower limit + S MAX=$G(^VPRCONFIG("maxStringLimit"),3641000) + ; this loop has to keep a running count of the length of all argument nodes added together, because they will be concatenated + ; together later on in VPRJPR (E.g. INDEX^VPRJPR) + F S NODE=$O(ARGS(NODE)) Q:(NODE="")!(BAIL) S COUNT=COUNT+$L(ARGS(NODE)) S:COUNT>MAX BAIL=1 I $D(ARGS(NODE,"\"))=10 D + . S LINE=0 + . F S LINE=$O(ARGS(NODE,"\",LINE)) Q:(LINE="")!(BAIL) D + . . S COUNT=COUNT+$L(ARGS(NODE,"\",LINE)) + . . I COUNT>MAX S BAIL=1 Q + . . S ARGS(NODE)=ARGS(NODE)_ARGS(NODE,"\",LINE) + . K ARGS(NODE,"\") + I BAIL D SETERROR^VPRJRER(114,"POST query parameters exceed argument length limit") + QUIT BAIL + ; SENDATA ; write out the data as an HTTP response ; expects HTTPERR to contain the HTTP error code, if any ; RSPTYPE=1 local variable - ; RSPTYPE=2 data in ^TMP($J) - ; RSPTYPE=3 pageable data in ^TMP($J,"data") or ^VPRTMP(hash,"data") - N SIZE,RSPTYPE,PREAMBLE,START,LIMIT + ; RSPTYPE=2 data in ^||TMP($J) + ; RSPTYPE=3 pageable data in ^||TMP($J,"data") or ^VPRTMP(hash,"data") + N SIZE,RSPTYPE,PREAMBLE,START,LIMIT,STARTID,RETCNTS S RSPTYPE=$S($E($G(HTTPRSP))'="^":1,$D(HTTPRSP("pageable")):3,1:2) I RSPTYPE=1 S SIZE=$$VARSIZE^VPRJRUT(.HTTPRSP) I RSPTYPE=2 S SIZE=$$REFSIZE^VPRJRUT(.HTTPRSP) I RSPTYPE=3 D - . S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2) - . D PAGE^VPRJRUT(.HTTPRSP,START,LIMIT,.SIZE,.PREAMBLE) + . S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2),STARTID=$G(HTTPRSP("startid")) + . S RETCNTS=$S(HTTPREQ("returncounts")="true":1,1:0) + . I STARTID'="" F I=1:1:$G(@HTTPRSP@("total")) I $D(@HTTPRSP@("data",I,STARTID)) S START=START+I Q + . D PAGE^VPRJRUT(.HTTPRSP,START,LIMIT,.SIZE,.PREAMBLE,RETCNTS) . ; if an error was generated during the paging, switch to return the error . I $G(HTTPERR) D RSPERROR S RSPTYPE=2,SIZE=$$REFSIZE^VPRJRUT(.HTTPRSP) ; @@ -83,9 +114,9 @@ S HTTPREQ("store")=$S($E(LOWPATH,2,9)="vpr/all/":"xvpr",$E(LOWPATH,2,4)="vpr":"v W "Content-Type: application/json"_$C(13,10) W "Access-Control-Allow-Origin: *"_$C(13,10) W "Content-Length: ",SIZE,$C(13,10)_$C(13,10) - I 'SIZE W $C(13,10),! Q ; flush buffer and quit + I 'SIZE W $C(13,10),! QUIT ; flush buffer and quit ; - N I,J + N I,J,HASDATA I RSPTYPE=1 D ; write out local variable . I $D(HTTPRSP)#2 W HTTPRSP . I $D(HTTPRSP)>1 S I=0 F S I=$O(HTTPRSP(I)) Q:'I W HTTPRSP(I) @@ -97,19 +128,21 @@ S HTTPREQ("store")=$S($E(LOWPATH,2,9)="vpr/all/":"xvpr",$E(LOWPATH,2,4)="vpr":"v . F I=START:1:(START+LIMIT-1) Q:'$D(@HTTPRSP@($J,I)) D . . I I>START W "," ; separate items with a comma . . S J="" F S J=$O(@HTTPRSP@($J,I,J)) Q:'J W @HTTPRSP@($J,I,J) - . W $S('$D(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")):"]}}",1:"]}") - . K @HTTPRSP@($J) + . S HASDATA=$D(@HTTPRSP@($J)) + . W $S('$D(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")):"]}}",+HASDATA:"]}",1:"}") + . K:$D(@HTTPRSP@($J)) @HTTPRSP@($J) W ! ; flush buffer - I RSPTYPE=3,($E(HTTPRSP,1,4)="^TMP") D UPDCACHE - Q + I RSPTYPE=3,(($E(HTTPRSP,1,4)="^TMP")!($E(HTTPRSP,1,6)="^||TMP")) D UPDCACHE + QUIT + ; UPDCACHE ; update the cache for this query I HTTPREQ("store")="data" G UPD4DATA I HTTPREQ("store")="xvpr" Q ; don't cache cross patient for now ; otherwise drop into VPR cache update UPD4VPR ; N PID,INDEX,HASH,HASHTS,MTHD,JPID - S PID=$G(^TMP($J,"pid")),INDEX=$G(^TMP($J,"index")) - S HASH=$G(^TMP($J,"hash")),HASHTS=$G(^TMP($J,"timestamp")) + S PID=$G(^||TMP($J,"pid")),INDEX=$G(^||TMP($J,"index")) + S HASH=$G(^||TMP($J,"hash")),HASHTS=$G(^||TMP($J,"timestamp")) Q:'$L(PID) Q:'$L(INDEX) Q:'$L(HASH) Q:PID["," ; S JPID=$$JPID4PID^VPRJPR(PID) @@ -117,29 +150,29 @@ I HTTPREQ("store")="data" G UPD4DATA S MTHD=$G(^VPRMETA("index",INDEX,"common","method")) L +^VPRTMP(HASH):$G(^VPRCONFIG("timeout","odhash"),1) E Q I $G(^VPRPTI(JPID,PID,MTHD,INDEX))=HASHTS D - . K ^VPRTMP(HASH) - . M ^VPRTMP(HASH)=^TMP($J) + . K:$D(^VPRTMP(HASH)) ^VPRTMP(HASH) + . M ^VPRTMP(HASH)=^||TMP($J) . S ^VPRTMP(HASH,"created")=$H . S ^VPRTMP("PID",PID,HASH)="" L -^VPRTMP(HASH) Q UPD4DATA ; N INDEX,HASH,HASHTS,MTHD - S INDEX=$G(^TMP($J,"index")) - S HASH=$G(^TMP($J,"hash")),HASHTS=$G(^TMP($J,"timestamp")) + S INDEX=$G(^||TMP($J,"index")) + S HASH=$G(^||TMP($J,"hash")),HASHTS=$G(^||TMP($J,"timestamp")) Q:'$L(INDEX) Q:'$L(HASH) ; S MTHD=$G(^VPRMETA("index",INDEX,"common","method")) L +^VPRTMP(HASH):$G(^VPRCONFIG("timeout","pthash"),1) E Q I $G(^VPRJDX(MTHD,INDEX))=HASHTS D - . K ^VPRTMP(HASH) - . M ^VPRTMP(HASH)=^TMP($J) + . K:$D(^VPRTMP(HASH)) ^VPRTMP(HASH) + . M ^VPRTMP(HASH)=^||TMP($J) . S ^VPRTMP(HASH,"created")=$H L -^VPRTMP(HASH) Q RSPERROR ; set response to be an error response - D ENCODE^VPRJSON("^TMP(""HTTPERR"",$J,1)","^TMP(""HTTPERR"",$J,""JSON"")") - S HTTPRSP="^TMP(""HTTPERR"",$J,""JSON"")" + D ENCODE^VPRJSON("^||TMP(""HTTPERR"",$J,1)","^||TMP(""HTTPERR"",$J,""JSON"")") + S HTTPRSP="^||TMP(""HTTPERR"",$J,""JSON"")" K HTTPRSP("pageable") Q RSPLINE() ; writes out a response line based on HTTPERR diff --git a/VPRJRUT.m b/VPRJRUT.m old mode 100755 new mode 100644 index 6dadd2a..59a1692 --- a/VPRJRUT.m +++ b/VPRJRUT.m @@ -1,5 +1,4 @@ -VPRJRUT ;SLC/KCM -- Utilities for HTTP communications;2017-05-25 5:09 PM - ;;1.0;JSON DATA STORE;;Sep 01, 2012 +VPRJRUT ;SLC/KCM -- Utilities for HTTP communications;2017-12-28 2:05 PM ; LOW(X) Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz") ; @@ -59,10 +58,10 @@ I $D(V)>1 S I="" F S I=$O(V(I)) Q:'I S SIZE=SIZE+$L(V(I)) Q SIZE ; -PAGE(ROOT,START,LIMIT,SIZE,PREAMBLE) ; create the size and preamble for a page of data - Q:'$D(ROOT) Q:'$L(ROOT) - N I,J,KEY,KINST,COUNT,TEMPLATE,PID - K @ROOT@($J) +PAGE(ROOT,START,LIMIT,SIZE,PREAMBLE,RETCNTS) ; create the size and preamble for a page of data + QUIT:'$D(ROOT) QUIT:'$L(ROOT) + N I,J,KEY,KINST,COUNT,TEMPLATE,PID,HASDATA + K:$D(@ROOT@($J)) @ROOT@($J) S SIZE=0,COUNT=0,TEMPLATE=$G(@ROOT@("template"),0) ;,PID=$G(@ROOT@("pid")) I $L(TEMPLATE) D LOADSPEC^VPRJCT1(.TEMPLATE) F I=START:1:(START+LIMIT-1) Q:'$D(@ROOT@("data",I)) S COUNT=COUNT+1 D @@ -71,11 +70,14 @@ . . . S PID=^(KINST) ; null if non-pt data . . . D TMPLT(ROOT,.TEMPLATE,I,KEY,KINST,PID) . . . S J="" F S J=$O(@ROOT@($J,I,J)) Q:'J S SIZE=SIZE+$L(@ROOT@($J,I,J)) - S PREAMBLE=$S('$D(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")):$$BLDHEAD(@ROOT@("total"),COUNT,START,LIMIT),1:"{""items"":[") + S HASDATA=$D(@ROOT@($J)) + S RETCNTS=$G(RETCNTS,0) + S PREAMBLE=$S('$D(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")):$$BLDHEAD(@ROOT@("total"),COUNT,START,LIMIT),1:$$GDSHEAD(HASDATA,RETCNTS,@ROOT@("total"),COUNT)) ; for vpr or data stores add 3 for "]}}", add COUNT-1 for commas - ; for other data stores add 2 for "]}", add COUNT-1 for commas - S SIZE=$S('$D(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")):SIZE+$L(PREAMBLE)+3+COUNT-$S('COUNT:0,1:1),1:SIZE+$L(PREAMBLE)+2+COUNT-$S('COUNT:0,1:1)) - Q + ; for other data stores add 1 for "}" if no data, 2 for "]}" if data present, add COUNT-1 for commas + S SIZE=$S('$D(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")):SIZE+$L(PREAMBLE)+3+COUNT-$S('COUNT:0,1:1),1:SIZE+$L(PREAMBLE)+$S(HASDATA:2,1:1)+COUNT-$S('COUNT:0,1:1)) + QUIT + ; TMPLT(ROOT,TEMPLATE,ITEM,KEY,KINST,PID) ; set template I HTTPREQ("store")="vpr" G TLT4VPR I HTTPREQ("store")="data" G TLT4DATA @@ -121,24 +123,37 @@ I HTTPREQ("store")'="" G TLT4GDS S STAMP=$O(^VPRJDJ("JSON",KEY,""),-1) M @ROOT@($J,ITEM)=^VPRJDJ("JSON",KEY,STAMP) Q -TLT4GDS ; +TLT4GDS ; Apply templates for GDS data stores to returned data + ; called from PAGE + ; N GLOBAL,GLOBALJ ; Parsed JSON S GLOBAL="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global")) ; Raw JSON S GLOBALJ="^"_$G(^VPRCONFIG("store",$G(HTTPREQ("store")),"global"))_"J" ; - ; called from PAGE - I $G(TEMPLATE)="uid" S @ROOT@($J,ITEM,1)="{""uid"":"""_KEY_"""}" Q - I $E(TEMPLATE,1,4)="rel;" D RELTLTD^VPRJCT1($NA(@ROOT@($J,ITEM)),KEY,.TEMPLATE) Q - I $E(TEMPLATE,1,4)="rev;" D REVTLTD^VPRJCT1($NA(@ROOT@($J,ITEM)),KEY,.TEMPLATE) Q + I $G(TEMPLATE)="uid" S @ROOT@($J,ITEM,1)="{""uid"":"""_KEY_"""}" QUIT + I $E(TEMPLATE,1,4)="rel;" D RELTLTD^VPRJCT1($NA(@ROOT@($J,ITEM)),KEY,.TEMPLATE) QUIT + I $E(TEMPLATE,1,4)="rev;" D REVTLTD^VPRJCT1($NA(@ROOT@($J,ITEM)),KEY,.TEMPLATE) QUIT + ; ; query time template - I $D(TEMPLATE)>1 D APPLYTLT Q - ; other template - I $L(TEMPLATE),$D(@GLOBALJ@("TEMPLATE",KEY,TEMPLATE)) M @ROOT@($J,ITEM)=^(TEMPLATE) Q - ; else full object + ; not supported + ;I $D(TEMPLATE)>1 D APPLYTLT Q + ; + ; If there is a template apply it + I $L(TEMPLATE),$D(@GLOBALJ@("TEMPLATE",KEY,TEMPLATE)) D QUIT + . ; GDS data stores require a lock on each data item before it is added to the result + . L +@GLOBAL@(KEY):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q + . M @ROOT@($J,ITEM)=@GLOBALJ@("TEMPLATE",KEY,TEMPLATE) + . L -@GLOBAL@(KEY) + ; + ; Else return the full object + ; GDS data stores require a lock on each data item before it is added to the result + L +@GLOBAL@(KEY):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) QUIT M @ROOT@($J,ITEM)=@GLOBALJ@("JSON",KEY) - Q + L -@GLOBAL@(KEY) + QUIT + ; APPLYTLT ; apply query time template ; called from TLT4VPR, TLT4XVPR, TLT4DATA ; expects TEMPLATE, KEY, KINST, PID, ROOT, ITEM @@ -157,6 +172,15 @@ I HTTPREQ("store")'="" G TLT4GDS D APPLY^VPRJCT(.SPEC,.OBJECT,.JSON,KINST) M @ROOT@($J,ITEM)=JSON Q + ; +GDSHEAD(HASDATA,RETCNTS,TOTAL,COUNT) ; Build object header for generic data stores + N X + S X="{" + I RETCNTS S X=X_"""totalItems"":"_TOTAL_",""currentItemCount"":"_COUNT + I RETCNTS,HASDATA S X=X_"," + I HASDATA S X=X_"""items"":[" + QUIT X + ; BLDHEAD(TOTAL,COUNT,START,LIMIT) ; Build the object header N X,UPDATED S UPDATED=$$CURRTIME @@ -193,61 +217,37 @@ I HTTPREQ("store")'="" G TLT4GDS Q 0 ; HASH(X) ; return CRC-32 of string contained in X - Q $$CRC32(X) ; support both GT.M and Cache + Q $ZCRC(X,7) ; return the CRC-32 value ; GMT() ; return HTTP date string (this is really using UTC instead of GMT) - ; from Sam Habiel N TM,DAY - I $$UP($ZV)["CACHE" D Q $P(DAY," ")_", "_$ZDATETIME(TM,2)_" GMT" - . S TM=$ZTIMESTAMP,DAY=$ZDATETIME(TM,11) - ; - N OUT - I $$UP($ZV)["GT.M" D Q OUT - . N D S D="datetimepipe" - . N OLDIO S OLDIO=$I - . O D:(shell="/bin/sh":comm="date -u +'%a, %d %b %Y %H:%M:%S %Z'|sed 's/UTC/GMT/g'")::"pipe" - . U D R OUT:1 - . U OLDIO C D - ; - QUIT "UNIMPLEMENTED" + S TM=$ZTIMESTAMP,DAY=$ZDATETIME(TM,11) + Q $P(DAY," ")_", "_$ZDATETIME(TM,2)_" GMT" ; SYSID() ; return a likely unique system ID N X - S X=$SYSTEM_":"_$G(^VPRHTTP("port"),9080) ; from Sam Habiel - Q $$CRC16HEX(X) ; return CRC16 in HEX - ; - ; Begin from Sam Habiel -CRC16HEX(X) ; return CRC-16 in hexadecimal - QUIT $$BASE($$CRC16(X),10,16) ; return CRC-16 in hex - ; -CRC32HEX(X) ; return CRC-32 in hexadecimal - QUIT $$BASE($$CRC32(X),10,16) ; return CRC-32 in hex + S X=$ZUTIL(110)_":"_$P($PRINCIPAL,"|",3) + Q $ZHEX($ZCRC(X,6)) ; DEC2HEX(NUM) ; return a decimal number as hex - Q $$BASE(NUM,10,16) - ;Q $ZHEX(NUM) + Q $ZHEX(NUM) ; HEX2DEC(HEX) ; return a hex number as decimal - Q $$BASE(HEX,16,10) - ;Q $ZHEX(HEX_"H") + Q $ZHEX(HEX_"H") ; WR4HTTP ; open file to save HTTP response - I $$UP($ZV)["CACHE" O "VPRJT.TXT":"WNS" - I $$UP($ZV)["GT.M" O "VPRJT.TXT":(newversion) + O "VPRJT.TXT":"WNS" ; open for writing U "VPRJT.TXT" Q RD4HTTP() ; read HTTP body from file and return as value N X - I $$UP($ZV)["CACHE" O "VPRJT.TXT":"RSD" ; read sequential and delete afterwards - I $$UP($ZV)["GT.M" O "VPRJT.TXT":(readonly:rewind) ; read sequential from the top. + O "VPRJT.TXT":"RSD" ; for reading and delete when done U "VPRJT.TXT" - F R X:1 S X=$TR(X,$C(13)) Q:'$L(X) ; read lines until there is an empty one ($TR for GT.M) + F R X:1 Q:'$L(X) ; read lines until there is an empty one R X:2 ; now read the JSON object - I $$UP($ZV)["GT.M" C "VPRJT.TXT":(delete) U $P - I $$UP($ZV)["CACHE" D C4HTTP + D C4HTTP Q X ; - ; End from Sam Habiel C4HTTP ; close file used for HTTP response C "VPRJT.TXT" U $P @@ -277,55 +277,3 @@ F D READLN(.LINE) Q:EOF S I=I+1 S BODY(I)=LINE S LEN=14-$L(TIME) S TIME=TIME_$E("00",1,LEN) Q TIME - ; - ; From Sam Habiel -CRC32(string,seed) ; - ; Polynomial X**32 + X**26 + X**23 + X**22 + - ; + X**16 + X**12 + X**11 + X**10 + - ; + X**8 + X**7 + X**5 + X**4 + - ; + X**2 + X + 1 - N I,J,R - I '$D(seed) S R=4294967295 - E I seed'<0,seed'>4294967295 S R=4294967295-seed - E S $ECODE=",M28," - F I=1:1:$L(string) D - . S R=$$XOR($A(string,I),R,8) - . F J=0:1:7 D - . . I R#2 S R=$$XOR(R\2,3988292384,32) - . . E S R=R\2 - . . Q - . Q - Q 4294967295-R -XOR(a,b,w) N I,M,R - S R=b,M=1 - F I=1:1:w D - . S:a\M#2 R=R+$S(R\M#2:-M,1:M) - . S M=M+M - . Q - Q R -BASE(%X1,%X2,%X3) ;Convert %X1 from %X2 base to %X3 base - I (%X2<2)!(%X2>16)!(%X3<2)!(%X3>16) Q -1 - Q $$CNV($$DEC(%X1,%X2),%X3) -DEC(N,B) ;Cnv N from B to 10 - Q:B=10 N N I,Y S Y=0 - F I=1:1:$L(N) S Y=Y*B+($F("0123456789ABCDEF",$E(N,I))-2) - Q Y -CNV(N,B) ;Cnv N from 10 to B - Q:B=10 N N I,Y S Y="" - F I=1:1 S Y=$E("0123456789ABCDEF",N#B+1)_Y,N=N\B Q:N<1 - Q Y -CRC16(string,seed) ; - ; Polynomial x**16 + x**15 + x**2 + x**0 - N I,J,R - I '$D(seed) S R=0 - E I seed'<0,seed'>65535 S R=seed\1 - E S $ECODE=",M28," - F I=1:1:$L(string) D - . S R=$$XOR($A(string,I),R,8) - . F J=0:1:7 D - . . I R#2 S R=$$XOR(R\2,40961,16) - . . E S R=R\2 - . . Q - . Q - Q R - ; End from Sam Habiel diff --git a/VPRJSES.m b/VPRJSES.m old mode 100755 new mode 100644 index ed0df62..ee8da6c --- a/VPRJSES.m +++ b/VPRJSES.m @@ -12,7 +12,7 @@ L +^VPRJSES(SID):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q "" TSTART I $O(^VPRJSES(SID,""))']"" S INCR=$I(^VPRJSES(0)) - K ^VPRJSES(SID) + K:$D(^VPRJSES(SID)) ^VPRJSES(SID) M ^VPRJSES(SID)=DEMOG TCOMMIT L -^VPRJSES(SID) @@ -24,7 +24,7 @@ L +^VPRJSES:$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q S VPRJA=0 TSTART - F S VPRJA=$O(^VPRJSES(VPRJA)) Q:VPRJA']"" K ^VPRJSES(VPRJA) + F S VPRJA=$O(^VPRJSES(VPRJA)) Q:VPRJA']"" K:$D(^VPRJSES(VPRJA)) ^VPRJSES(VPRJA) S ^VPRJSES(0)=0 TCOMMIT L -^VPRJSES @@ -37,7 +37,7 @@ I $D(^VPRJSES(ARGS("_id"))) D .L +^VPRJSES(ARGS("_id")):$G(^VPRCONFIG("timeout","gds"),5) .TSTART - .K ^VPRJSES(ARGS("_id")) + .K:$D(^VPRJSES(ARGS("_id"))) ^VPRJSES(ARGS("_id")) .TCOMMIT .L -^VPRJSES(ARGS("_id")) S RESULT="{}" diff --git a/VPRJSON.m b/VPRJSON.m old mode 100755 new mode 100644 diff --git a/VPRJSOND.m b/VPRJSOND.m old mode 100755 new mode 100644 index 00b6821..5e468a4 --- a/VPRJSOND.m +++ b/VPRJSOND.m @@ -1,4 +1,4 @@ -VPRJSOND ;SLC/KCM -- Decode JSON +VPRJSOND ;SLC/KCM,CPC -- Decode JSON ;;1.0;VIRTUAL PATIENT RECORD;**2,3**;Sep 01, 2011;Build 50 ; DECODE(VVJSON,VVROOT,VVERR) ; Set JSON object into closed array ref VVROOT @@ -18,8 +18,8 @@ ; ; V4W/DLW - Changed VVMAX from 4000 to 100, same as in the encoder ; With the change to VVMAX, the following Unit Tests required changes: - ; SPLITA^VPRJUJD, SPLITB^VPRJUJD, LONG^VPRJUJD, MAXNUM^VPRJUJD - N VVMAX S VVMAX=100 ; limit document lines to 100 characters + ; SPLITA^VPRJUJD, SPLITB^VPRJUJD, LONG^VPRJUJD, MAXNUM^VPRJUJD + N VVMAX S VVMAX=$G(^VPRCONFIG("vvmax","decoder"),100) ; limit document lines to VVMAX S VVERR=$G(VVERR,"^TMP(""VPRJERR"",$J)") ; If a simple string is passed in, move it to an temp array (VVINPUT) ; so that the processing is consistently on an array. @@ -30,6 +30,7 @@ F S VVTYPE=$$NXTKN() Q:VVTYPE="" D I VVERRORS Q . I VVTYPE="{" S VVSTACK=VVSTACK+1,VVSTACK(VVSTACK)="",VVPROP=1 D:VVSTACK>64 ERRX("STL{") Q . I VVTYPE="}" D QUIT + . . I VVSTACK=0 D ERRX("SUF}") Q ;DE8232 . . I +VVSTACK(VVSTACK)=VVSTACK(VVSTACK),VVSTACK(VVSTACK) D ERRX("OBM") ; Numeric and true only . . S VVSTACK=VVSTACK-1 D:VVSTACK<0 ERRX("SUF}") . I VVTYPE="[" S VVSTACK=VVSTACK+1,VVSTACK(VVSTACK)=1 D:VVSTACK>64 ERRX("STL[") Q diff --git a/VPRJSONE.m b/VPRJSONE.m old mode 100755 new mode 100644 index cad4bcb..f87e128 --- a/VPRJSONE.m +++ b/VPRJSONE.m @@ -27,7 +27,7 @@ ; REV1^VPRJTCT1, REV2^VPRJTCT1, REV3^VPRJTCT1, PURENUM^VPRJUJD, ; ESTRING^VPRJUJD, BASIC^VPRJUJE, VALS^VPRJUJE, LONG^VPRJUJE, ; PRE^VPRJUJE, WP^VPRJUJE, EXAMPLE^VPRJUJE - S VVLINE=1,VVMAX=100,VVERRORS=0 ; limit document lines to 100 characters + S VVLINE=1,VVMAX=$G(^VPRCONFIG("vvmax","encoder"),100),VVERRORS=0 ; limit document lines to VVMAX S @VVJSON@(VVLINE)="" D SEROBJ(VVROOT) Q diff --git a/VPRJT.m b/VPRJT.m old mode 100755 new mode 100644 index 5df5a94..4060611 --- a/VPRJT.m +++ b/VPRJT.m @@ -1,5 +1,4 @@ VPRJT ;SLC/KCM -- Unit test driver - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; ;with acknowlegements to XTMUNIT, Imitation is the sincerest form of flattery ; @@ -39,7 +38,7 @@ D EN(ZZLIST) . . S ZZK=$T(@("SETUP^"_ZZROU)) I $L(ZZK) D @("SETUP^"_ZZROU) . . D @(ZZLABEL_"^"_ZZROU) ; run the unit test . . S ZZK=$T(@("TEARDOWN^"_ZZROU)) I $L(ZZK) D @("TEARDOWN^"_ZZROU) - . . ;W ! ZW ; normally comment out except when looking for non-newed variables + . . ;W ! ZWRITE ; normally comment out except when looking for non-newed variables ; S ZZK=$T(@("SHUTDOWN^"_ZZROU)) I $L(ZZK) D @("SHUTDOWN^"_ZZROU) Q @@ -62,48 +61,55 @@ D EN(ZZLIST) Q $E(X,POS,$L(X)) ; EACH ; run each test one at a time - ;;VPRJUJD -- Unit tests for JSON decoding - ;;VPRJUJE -- Unit tests for JSON encoding - ;;VPRJUREQ -- Unit tests for HTTP listener request handling - ;;VPRJURSP -- Unit tests for HTTP listener response handling - ;;VPRJURUT -- Unit tests for HTTP listener utilities - ;;VPRJUCU -- Unit tests for common utilities - ;;VPRJUCV -- Unit tests for extracting values from objects - ;;VPRJUCD -- Unit tests for building meta-data - ;;VPRJUCD1 -- Unit tests for building templates - ;;VPRJUCT -- Unit tests for applying templates - ;;VPRJUCF -- Unit tests for filter parameter - ;;VPRJUCR -- Unit tests for range parameter parsing - ;;VPRJUFPS -- Unit tests for index functions - ;;VPRJTCF -- Integration tests for query filters - ;;VPRJTCT -- Integration tests for templates - ;;VPRJTCT1 -- Integration tests for rel/rev templates - ;;VPRJTDS -- Integration tests for saving objects to ODC - ;;VPRJTDR -- Integration tests for ODS RESTful queries - ;;VPRJTDR2 -- Integration tests for ODS RESTful templates - ;;VPRJTDM -- Integration tests for ODS management tools - ;;VPRJTPS -- Integration tests for saving patient objects - ;;VPRJTPQ -- Integration tests for query indexes - ;;VPRJTPR -- Integration tests for RESTful queries - ;;VPRJTPR1 -- Integration tests for RESTful paging - ;;VPRJTPR2 -- Integration tests for RESTful templates - ;;VPRJTPR3 -- Integration tests for multi-patient RESTful queries - ;;VPRJTSYST -- Unit tests for GET Patient Sync Status - ;;VPRJTSYSS -- Unit tests for SET Patient Sync Status - ;;VPRJTJOB -- Unit tests for Job Status - ;;VPRJTPATID -- Unit tests for Patient Indentifiers - ;;VPRJTSES -- Unit tests for Session Storage - ;;VPRJTODM -- Unit tests for Operational Data Mutable Storage - ;;VPRJTSYNCOD -- Unit tests for Operational Sync Status - ;;VPRJTHDR -- Integration tests for Patient Data and HDR - ;;VPRJTGC -- Unit tests for Garbage Collection - ;;VPRJTERR -- Unit tests for Error Storage - ;;VPRJTGDS -- Unit tests for Generic Data Storage - ;;VPRJTPL -- Integration tests for RESTful patient list queries - ;;VPRJTPSTATUS -- Unit/Integration tests for simple patient sync status - ;;VPRJTAR -- Special tests for RESTful queries across patients + ;;VPRJUJD -- Unit tests for JSON decoding + ;;VPRJUJE -- Unit tests for JSON encoding + ;;VPRJUREQ -- Unit tests for HTTP listener request handling + ;;VPRJURSP -- Unit tests for HTTP listener response handling + ;;VPRJURUT -- Unit tests for HTTP listener utilities + ;;VPRJUCU -- Unit tests for common utilities + ;;VPRJUCV -- Unit tests for extracting values from objects + ;;VPRJUCD -- Unit tests for building meta-data + ;;VPRJUCD1 -- Unit tests for building templates + ;;VPRJUCT -- Unit tests for applying templates + ;;VPRJUCF -- Unit tests for filter parameter + ;;VPRJUCR -- Unit tests for range parameter parsing + ;;VPRJUFPS -- Unit tests for index functions + ;;VPRJTCF -- Integration tests for query filters + ;;VPRJTCT -- Integration tests for templates + ;;VPRJTCT1 -- Integration tests for rel/rev templates + ;;VPRJTDS -- Integration tests for saving objects to ODC + ;;VPRJTDR -- Integration tests for ODS RESTful queries + ;;VPRJTDR2 -- Integration tests for ODS RESTful templates + ;;VPRJTDM -- Integration tests for ODS management tools + ;;VPRJTPS -- Integration tests for saving patient objects + ;;VPRJTPQ -- Integration tests for query indexes + ;;VPRJTPR -- Integration tests for RESTful queries + ;;VPRJTPR1 -- Integration tests for RESTful paging + ;;VPRJTPR2 -- Integration tests for RESTful templates + ;;VPRJTPR3 -- Integration tests for multi-patient RESTful queries + ;;VPRJTPDI -- Integration tests for document indexes + ;;VPRJTSYST -- Unit tests for GET Patient Sync Status + ;;VPRJTSYSS -- Unit tests for SET Patient Sync Status + ;;VPRJTJOB -- Unit tests for Job Status + ;;VPRJTPATID -- Unit tests for Patient Indentifiers + ;;VPRJTSES -- Unit tests for Session Storage + ;;VPRJTODM -- Unit tests for Operational Data Mutable Storage + ;;VPRJTSYNCOD -- Unit tests for Operational Sync Status + ;;VPRJTHDR -- Integration tests for Patient Data and HDR + ;;VPRJTGC -- Unit tests for Garbage Collection + ;;VPRJTERR -- Unit tests for Error Storage + ;;VPRJTGDS -- Unit tests for Generic Data Storage + ;;VPRJTPL -- Integration tests for RESTful patient list queries + ;;VPRJTPSTATUS -- Unit/Integration tests for simple patient sync status + ;;VPRJTAR -- Special tests for RESTful queries across patients + ;;VPRJTQP -- Integration tests for POST queries + ;;VPRJT2D -- Integration tests for operational utilities + ;;VPRJT2P -- Integration tests for patient utilities + ;;VPRJTPRN -- Unit tests for individual patient data wrapper code for jdsClient using cache.node + ;;VPRJTDRN -- Unit tests for operational data wrapper code for jdsClient using cache.node + ;;VPRJTGDSN -- Unit tests for generic data store wrapper code for pjdsClient using cache.node ;;zzzzz ;; N ZZZ S ZZZ=0 - F S ZZZ=ZZZ+1 Q:$P($P($T(EACH+ZZZ),";;",2,99)," ")="zzzzz" D EN($P($P($T(EACH+ZZZ),";;",2,99)," ")) ;W ! ZW + F S ZZZ=ZZZ+1 Q:$P($P($T(EACH+ZZZ),";;",2,99)," ")="zzzzz" D EN($P($P($T(EACH+ZZZ),";;",2,99)," ")) ;W ! ZWRITE Q diff --git a/VPRJT2D.m b/VPRJT2D.m new file mode 100644 index 0000000..d6c2436 --- /dev/null +++ b/VPRJT2D.m @@ -0,0 +1,124 @@ +VPRJT2D ;V4W/DLW -- Integration tests for operational utilities + ; +STARTUP ; Run once before all tests + D ODSCLR^VPRJTX + QUIT + ; +SHUTDOWN ; Run once after all tests + D ODSCLR^VPRJTX + QUIT + ; +SETUP ; Run before each test + D ODSCLR^VPRJTX + QUIT + ; +TEARDOWN ; Run after each test + D ODSCLR^VPRJTX + QUIT + ; +ASSERT(EXPECT,ACTUAL,MSG) ; for convenience + D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) + QUIT + ; +BUILD ; Build up test data + N DATA,LOC + D GETDATA^VPRJTX("TEST1","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("TEST2","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("TEST3","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("TEST4","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("TEST5","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("TEST6","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("TEST7","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + K DATA,LOC + D GETDATA^VPRJTX("LINK1","VPRJTD01",.DATA) + S LOC=$$SAVE^VPRJDS(.DATA) + ; + QUIT + ; +RIDXALL ;; @TEST reindexing all operational data indexes + D BUILD + ; + D ASSERT(1,$D(^VPRJDX("attr","test-name","alpha ","798789799542=","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","test-name","omega ","798789768244=","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","alpha ","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","omega ","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("rev","urn:va:test:2","utest-ods","urn:va:utestods:1","items#1"))) + D ASSERT(1,^VPRJDX("tally","test-name-count","alpha")) + D ASSERT(2,^VPRJDX("tally","test-name-count","delta")) + D ASSERT(7,^VPRJDX("count","collection","test")) + ; + D RIDXALL^VPRJ2D + ; + D ASSERT(1,$D(^VPRJDX("attr","test-name","alpha ","798789799542=","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","test-name","omega ","798789768244=","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","alpha ","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","omega ","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("rev","urn:va:test:2","utest-ods","urn:va:utestods:1","items#1"))) + D ASSERT(1,^VPRJDX("tally","test-name-count","alpha")) + D ASSERT(2,^VPRJDX("tally","test-name-count","delta")) + D ASSERT(7,^VPRJDX("count","collection","test")) + ; + QUIT + ; +RIDXONE ;; @TEST reindexing one operational data index + D BUILD + ; + D ASSERT(1,$D(^VPRJDX("attr","test-name","alpha ","798789799542=","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","test-name","omega ","798789768244=","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","alpha ","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","omega ","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("rev","urn:va:test:2","utest-ods","urn:va:utestods:1","items#1"))) + D ASSERT(1,^VPRJDX("tally","test-name-count","alpha")) + D ASSERT(2,^VPRJDX("tally","test-name-count","delta")) + D ASSERT(7,^VPRJDX("count","collection","test")) + ; + D RIDXALL^VPRJ2D("test-name") + ; + D ASSERT(1,$D(^VPRJDX("attr","test-name","alpha ","798789799542=","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","test-name","omega ","798789768244=","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","alpha ","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","omega ","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("rev","urn:va:test:2","utest-ods","urn:va:utestods:1","items#1"))) + D ASSERT(1,^VPRJDX("tally","test-name-count","alpha")) + D ASSERT(2,^VPRJDX("tally","test-name-count","delta")) + D ASSERT(7,^VPRJDX("count","collection","test")) + ; + QUIT + ; +RIDXSOME ;; @TEST reindexing some operational data indexes + D BUILD + ; + D ASSERT(1,$D(^VPRJDX("attr","test-name","alpha ","798789799542=","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","test-name","omega ","798789768244=","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","alpha ","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","omega ","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("rev","urn:va:test:2","utest-ods","urn:va:utestods:1","items#1"))) + D ASSERT(1,^VPRJDX("tally","test-name-count","alpha")) + D ASSERT(2,^VPRJDX("tally","test-name-count","delta")) + D ASSERT(7,^VPRJDX("count","collection","test")) + ; + D RIDXALL^VPRJ2D("test-name,utest-name") + ; + D ASSERT(1,$D(^VPRJDX("attr","test-name","alpha ","798789799542=","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","test-name","omega ","798789768244=","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","alpha ","urn:va:test:1",1))) + D ASSERT(1,$D(^VPRJDX("attr","utest-name","omega ","urn:va:test:7",1))) + D ASSERT(1,$D(^VPRJDX("rev","urn:va:test:2","utest-ods","urn:va:utestods:1","items#1"))) + D ASSERT(1,^VPRJDX("tally","test-name-count","alpha")) + D ASSERT(2,^VPRJDX("tally","test-name-count","delta")) + D ASSERT(7,^VPRJDX("count","collection","test")) + ; + QUIT diff --git a/VPRJT2P.m b/VPRJT2P.m new file mode 100644 index 0000000..3efa443 --- /dev/null +++ b/VPRJT2P.m @@ -0,0 +1,123 @@ +VPRJT2P ;V4W/DLW -- Integration tests for patient utilities + ; +STARTUP ; Run once before all tests + N I,TAGS + D PATIDS + F I=1:1:5 S TAGS(I)="MED"_I_"^VPRJTP02" + D BLDPT^VPRJTX(.TAGS) + QUIT + ; +SHUTDOWN ; Run once after all tests + D CLRPT^VPRJTX + QUIT + ; +ASSERT(EXPECT,ACTUAL,MSG) ; for convenience + D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) + QUIT + ; +PATIDS ; Setup patient identifiers + S ^VPRPTX("count","patient","patient")=2 + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","93EF;-7")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","-777V123777")="" + S ^VPRPTJ("JPID","93EF;-7")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","-777V123777")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2370")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2370","93EF;-8")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2370","-777V123778")="" + S ^VPRPTJ("JPID","93EF;-8")="52833885-af7c-4899-90be-b3a6630b2370" + S ^VPRPTJ("JPID","-777V123778")="52833885-af7c-4899-90be-b3a6630b2370" + QUIT + ; +RIDXALL ;; @TEST reindexing all patient data indexes + N PID,JPID + S PID="93EF;-7" + S JPID=$$JPID4PID^VPRJPR(PID) + ; + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-class-code","urn:vadc:hs502 ","79939681=","urn:va:med:93EF:-7:16982","products#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-provider","labtech,special ","79939681=","urn:va:med:93EF:-7:16982","orders#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-qualified-name","metformin ","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","medication","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT("79939681=",^VPRPTI(JPID,PID,"time","med-time","79949682=","urn:va:med:93EF:-7:16982",1)) + D ASSERT("79949682=",^VPRPTI(JPID,PID,"stop","med-time","79939681=","urn:va:med:93EF:-7:16982",1)) + D ASSERT(4,^VPRPTI(JPID,PID,"tally","kind","medication, outpatient")) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-active-outpt","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(5,^VPRPTX("count","collection","med")) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) + ; + D RIDXALL^VPRJ2P + ; + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-class-code","urn:vadc:hs502 ","79939681=","urn:va:med:93EF:-7:16982","products#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-provider","labtech,special ","79939681=","urn:va:med:93EF:-7:16982","orders#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-qualified-name","metformin ","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","medication","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT("79939681=",^VPRPTI(JPID,PID,"time","med-time","79949682=","urn:va:med:93EF:-7:16982",1)) + D ASSERT("79949682=",^VPRPTI(JPID,PID,"stop","med-time","79939681=","urn:va:med:93EF:-7:16982",1)) + D ASSERT(4,^VPRPTI(JPID,PID,"tally","kind","medication, outpatient")) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-active-outpt","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(5,^VPRPTX("count","collection","med")) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) + ; + QUIT + ; +RIDXONE ;; @TEST reindexing one patient data index + N PID,JPID + S PID="93EF;-7" + S JPID=$$JPID4PID^VPRJPR(PID) + ; + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-class-code","urn:vadc:hs502 ","79939681=","urn:va:med:93EF:-7:16982","products#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-provider","labtech,special ","79939681=","urn:va:med:93EF:-7:16982","orders#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-qualified-name","metformin ","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","medication","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT("79939681=",^VPRPTI(JPID,PID,"time","med-time","79949682=","urn:va:med:93EF:-7:16982",1)) + D ASSERT("79949682=",^VPRPTI(JPID,PID,"stop","med-time","79939681=","urn:va:med:93EF:-7:16982",1)) + D ASSERT(4,^VPRPTI(JPID,PID,"tally","kind","medication, outpatient")) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-active-outpt","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(5,^VPRPTX("count","collection","med")) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) + ; + D RIDXALL^VPRJ2P("med-qualified-name") + ; + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-class-code","urn:vadc:hs502 ","79939681=","urn:va:med:93EF:-7:16982","products#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-provider","labtech,special ","79939681=","urn:va:med:93EF:-7:16982","orders#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-qualified-name","metformin ","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","medication","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT("79939681=",^VPRPTI(JPID,PID,"time","med-time","79949682=","urn:va:med:93EF:-7:16982",1)) + D ASSERT("79949682=",^VPRPTI(JPID,PID,"stop","med-time","79939681=","urn:va:med:93EF:-7:16982",1)) + D ASSERT(4,^VPRPTI(JPID,PID,"tally","kind","medication, outpatient")) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-active-outpt","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(5,^VPRPTX("count","collection","med")) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) + ; + QUIT + ; +RIDXSOME ;; @TEST reindexing some patient data indexes + N PID,JPID + S PID="93EF;-7" + S JPID=$$JPID4PID^VPRJPR(PID) + ; + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-class-code","urn:vadc:hs502 ","79939681=","urn:va:med:93EF:-7:16982","products#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-provider","labtech,special ","79939681=","urn:va:med:93EF:-7:16982","orders#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-qualified-name","metformin ","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","medication","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT("79939681=",^VPRPTI(JPID,PID,"time","med-time","79949682=","urn:va:med:93EF:-7:16982",1)) + D ASSERT("79949682=",^VPRPTI(JPID,PID,"stop","med-time","79939681=","urn:va:med:93EF:-7:16982",1)) + D ASSERT(4,^VPRPTI(JPID,PID,"tally","kind","medication, outpatient")) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-active-outpt","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(5,^VPRPTX("count","collection","med")) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) + ; + D RIDXALL^VPRJ2P("med-class-code,med-qualified-name,med-provider") + ; + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-class-code","urn:vadc:hs502 ","79939681=","urn:va:med:93EF:-7:16982","products#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-provider","labtech,special ","79939681=","urn:va:med:93EF:-7:16982","orders#1"))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-qualified-name","metformin ","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","medication","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT("79939681=",^VPRPTI(JPID,PID,"time","med-time","79949682=","urn:va:med:93EF:-7:16982",1)) + D ASSERT("79949682=",^VPRPTI(JPID,PID,"stop","med-time","79939681=","urn:va:med:93EF:-7:16982",1)) + D ASSERT(4,^VPRPTI(JPID,PID,"tally","kind","medication, outpatient")) + D ASSERT(1,$D(^VPRPTI(JPID,PID,"attr","med-active-outpt","79939681=","urn:va:med:93EF:-7:16982",1))) + D ASSERT(5,^VPRPTX("count","collection","med")) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) + ; + QUIT diff --git a/VPRJTAR.m b/VPRJTAR.m old mode 100755 new mode 100644 index 709b64f..372bbc2 --- a/VPRJTAR.m +++ b/VPRJTAR.m @@ -1,8 +1,7 @@ VPRJTAR ;SLC/KCM -- Special tests for RESTful queries across patients - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; STARTUP ; Run once before all tests - K ^TMP($J),^TMP("HTTPERR",$J) + K ^||TMP($J),^||TMP("HTTPERR",$J) N I,TAGS F I=1:1:5 S TAGS(I)="MED"_I_"^VPRJTP02" D BLDPT^VPRJTX(.TAGS) @@ -15,7 +14,7 @@ K ^VPRPTJ K ^VPRPT K ^VPRMETA("JPID") - K ^TMP($J),^TMP("HTTPERR",$J) + K ^||TMP($J),^||TMP("HTTPERR",$J) Q SETUP ; Run before each test K HTTPREQ,HTTPERR,HTTPRSP @@ -27,6 +26,20 @@ D EQ^VPRJT(EXPECT,ACTUAL) Q ; + ; POST data for POST query tests +POSTDATA1 ;; test POST query data for FILTERSITE + ;;{"filter":"eq(site,93EF)"} + ;;zzzzz +POSTDATA2 ;; test POST query data for FILTERNOSITE + ;;{"filter":"ne(site,93EF)"} + ;;zzzzz +POSTDATA3 ;; test POST query data for FILTERSITE2 + ;;{"filter":"eq(site,1HDR)"} + ;;zzzzz +POSTDATA4 ;; test POST query data for FILTERNOSITE2 + ;;{"filter":"ne(site,1HDR)"} + ;;zzzzz + ; ; these should not be run like the other tests ; they cannot produce the same results each time since they work across patients ; @@ -34,13 +47,13 @@ D SETGET^VPRJTX("/vpr/all/find/med/uid?filter=like(""products[].ingredientName"",""ASPIRIN%25"")") D RESPOND^VPRJRSP D ASSERT(0,$D(HTTPERR)) - D ASSERT(1,($G(^TMP($J,"total"))>0)) + D ASSERT(1,($G(^||TMP($J,"total"))>0)) Q ALLINDEX ;; test index across patients D SETGET^VPRJTX("/vpr/all/index/pt-name") D RESPOND^VPRJRSP D ASSERT(0,$D(HTTPERR)) - D ASSERT(1,($G(^TMP($J,"total"))>0)) + D ASSERT(1,($G(^||TMP($J,"total"))>0)) D ASSERT(1,$D(HTTPRSP("pageable"))) Q ALLPID ;; test getting all patient PID's @@ -48,13 +61,13 @@ D ASSERT(1,$D(HTTPRSP("pageable"))) D RESPOND^VPRJRSP D ASSERT(0,$D(HTTPERR)) D ASSERT(0,$D(HTTPRSP("pageable"))) - D ASSERT(1,$P(^TMP($J,1),"""totalItems"":",2)>0) + D ASSERT(1,$P(^||TMP($J,1),"""totalItems"":",2)>0) Q ALLIDX2 ;; test index across patients D SETGET^VPRJTX("/vpr/all/index/xlab-lnc?range=urn:lnc:13955-0") D RESPOND^VPRJRSP D ASSERT(0,$D(HTTPERR)) - D ASSERT(1,($G(^TMP($J,"total"))>0)) + D ASSERT(1,($G(^||TMP($J,"total"))>0)) D ASSERT(1,$D(HTTPRSP("pageable"))) Q FILTERSITE ;; @test getting all patient PID's for a particular site @@ -62,36 +75,68 @@ D ASSERT(1,$D(HTTPRSP("pageable"))) D RESPOND^VPRJRSP D ASSERT(0,$G(HTTPERR)'=0) D ASSERT(0,$D(HTTPRSP("pageable"))) - D ASSERT(1,$P($P(^TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works - D ASSERT(1,^TMP($J,2)["93EF") - D ASSERT(0,^TMP($J,2)["1HDR") + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(1,^||TMP($J,2)["93EF") + D ASSERT(0,^||TMP($J,2)["1HDR") + ; test POST query version + D SETPOST^VPRJTX("/vpr/all/index/pid/pid?query=true","POSTDATA1","VPRJTAR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)'=0) + D ASSERT(0,$D(HTTPRSP("pageable"))) + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(1,^||TMP($J,2)["93EF") + D ASSERT(0,^||TMP($J,2)["1HDR") Q FILTERNOSITE ;; @test getting all patient PID's for every site except one D SETGET^VPRJTX("/vpr/all/index/pid/pid?filter=ne(site,93EF)") D RESPOND^VPRJRSP D ASSERT(0,$G(HTTPERR)'=0) D ASSERT(0,$D(HTTPRSP("pageable"))) - D ASSERT(1,$P($P(^TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works - D ASSERT(0,^TMP($J,2)["93EF") - D ASSERT(1,^TMP($J,2)["1HDR") + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(0,^||TMP($J,2)["93EF") + D ASSERT(1,^||TMP($J,2)["1HDR") + ; test POST query version + D SETPOST^VPRJTX("/vpr/all/index/pid/pid?query=true","POSTDATA2","VPRJTAR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)'=0) + D ASSERT(0,$D(HTTPRSP("pageable"))) + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(0,^||TMP($J,2)["93EF") + D ASSERT(1,^||TMP($J,2)["1HDR") Q FILTERSITE2 ;; @test getting all patient PID's for a particular site D SETGET^VPRJTX("/vpr/all/index/pid/pid?filter=eq(site,1HDR)") D RESPOND^VPRJRSP D ASSERT(0,$G(HTTPERR)'=0) D ASSERT(0,$D(HTTPRSP("pageable"))) - D ASSERT(1,$P($P(^TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works - D ASSERT(1,^TMP($J,2)["1HDR") - D ASSERT(0,^TMP($J,2)["93EF") + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(1,^||TMP($J,2)["1HDR") + D ASSERT(0,^||TMP($J,2)["93EF") + ; test POST query version + D SETPOST^VPRJTX("/vpr/all/index/pid/pid?query=true","POSTDATA3","VPRJTAR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)'=0) + D ASSERT(0,$D(HTTPRSP("pageable"))) + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(1,^||TMP($J,2)["1HDR") + D ASSERT(0,^||TMP($J,2)["93EF") Q FILTERNOSITE2 ;; @test getting all patient PID's for every site except one D SETGET^VPRJTX("/vpr/all/index/pid/pid?filter=ne(site,1HDR)") D RESPOND^VPRJRSP D ASSERT(0,$G(HTTPERR)'=0) D ASSERT(0,$D(HTTPRSP("pageable"))) - D ASSERT(1,$P($P(^TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works - D ASSERT(0,^TMP($J,2)["1HDR") - D ASSERT(1,^TMP($J,2)["93EF") + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(0,^||TMP($J,2)["1HDR") + D ASSERT(1,^||TMP($J,2)["93EF") + ; test POST query version + D SETPOST^VPRJTX("/vpr/all/index/pid/pid?query=true","POSTDATA4","VPRJTAR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)'=0) + D ASSERT(0,$D(HTTPRSP("pageable"))) + D ASSERT(1,$P($P(^||TMP($J,1),"""totalItems"":",2),",")=1) ; grab the value of totalItems to ensure the filter works + D ASSERT(0,^||TMP($J,2)["1HDR") + D ASSERT(1,^||TMP($J,2)["93EF") Q ALL ;; run all tests D STARTUP diff --git a/VPRJTCF.m b/VPRJTCF.m old mode 100755 new mode 100644 index 11d8c86..e570394 --- a/VPRJTCF.m +++ b/VPRJTCF.m @@ -2,7 +2,7 @@ ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; STARTUP ; Run once before all tests - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D BLDPT^VPRJTX D MOCK1 Q @@ -94,7 +94,7 @@ Q EVAL(LINE) ; return evaluation of statement N PID,UID,STMT,CLAUSES,HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) I LINE["+" S STMT=$P($T(@LINE),";;",2,99) E S STMT=LINE D PARSE^VPRJCF(STMT,.CLAUSES) diff --git a/VPRJTCT.m b/VPRJTCT.m old mode 100755 new mode 100644 index 860becb..35bd125 --- a/VPRJTCT.m +++ b/VPRJTCT.m @@ -46,8 +46,6 @@ D ASSERT(1,$D(OBJ("products",1,"ingredient"))) K JSON,OBJ M JSON=^VPRPTJ("TEMPLATE",VPRJPID,VPRJTPID,"urn:va:utesta:93EF:-7:1","unit-test-instance") D DECODE^VPRJSON("JSON","OBJ") - ;W ! ZW OBJ - ;B check to see that the appropriate JSON objects exist Q EXP1 ;; @TEST expanding fields in template N I,TAGS @@ -75,7 +73,7 @@ D ASSERT(0,$D(OBJ("items",3))) D ASSERT("urn:va:utestc:93EF:-7:23",$G(OBJ("uid"))) Q QUERY ;; @TEST query type template - K ^TMP + K ^||TMP N VPRJPID S VPRJPID=$$JPID4PID^VPRJPR(VPRJTPID) D ASSERT(0,$D(^VPRPTJ("TEMPLATE",VPRJPID,VPRJTPID,"urn:va:utestc:93EF:-7:23","unit-test-query"))) diff --git a/VPRJTCT1.m b/VPRJTCT1.m old mode 100755 new mode 100644 diff --git a/VPRJTD01.m b/VPRJTD01.m old mode 100755 new mode 100644 diff --git a/VPRJTDM.m b/VPRJTDM.m old mode 100755 new mode 100644 diff --git a/VPRJTDR.m b/VPRJTDR.m old mode 100755 new mode 100644 index 26aa0bb..090ceae --- a/VPRJTDR.m +++ b/VPRJTDR.m @@ -1,5 +1,4 @@ VPRJTDR ;SLC/KCM -- Integration tests for ODC RESTful queries - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; STARTUP ; Run once before all tests N I,TAGS @@ -19,6 +18,29 @@ D EQ^VPRJT(EXPECT,ACTUAL) Q ; + ; POST data for POST query tests +POSTDATA1 ;; test POST query data for INDEX and LAST + ;;{"range":"alpha..delta"} + ;;zzzzz +POSTDATA2 ;; test POST query data for ORDASC + ;;{"order":"name asc"} + ;;zzzzz +POSTDATA3 ;; test POST query data for ORDDESC + ;;{"order":"name DESC"} + ;;zzzzz +POSTDATA4 ;; test POST query data for ORDEMPTY + ;;{"order":"type DESC"} + ;;zzzzz +POSTDATA5 ;; test POST query data for FILTER + ;;{"filter":"eq(\"color\",\"orange\")"} + ;;zzzzz +POSTDATA6 ;; test POST query data for EVERY + ;;{"start":3,"limit":3} + ;;zzzzz +POSTDATA7 ;; test POST query data for FINDPAR + ;;{"filter":"eq(\"color\",\"orange\")","order":"name"} + ;;zzzzz + ; INDEX ;; @TEST query using an index N ROOT,JSON,ERR,HTTPERR D SETGET^VPRJTX("/data/index/test-name?range=alpha..delta") @@ -27,6 +49,14 @@ D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(4,JSON("data","totalItems")) D ASSERT(201110201857,JSON("data","items",4,"updated")) ; sorted reverse updated date + ; test POST query version + K ROOT,JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/index/test-name?query=true","POSTDATA1","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(4,JSON("data","totalItems")) + D ASSERT(201110201857,JSON("data","items",4,"updated")) ; sorted reverse updated date Q LAST ;; @TEST query for last instance of items in list N ROOT,JSON,ERR,HTTPERR @@ -36,6 +66,14 @@ D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(3,JSON("data","totalItems")) D ASSERT("urn:va:test:6",JSON("data","items",1,"uid")) + ; test POST query version + K ROOT,JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/last/test-name?query=true","POSTDATA1","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(3,JSON("data","totalItems")) + D ASSERT("urn:va:test:6",JSON("data","items",1,"uid")) Q ORDASC ;; @TEST query to return in different order N ROOT,JSON,ERR,HTTPERR @@ -44,6 +82,13 @@ D ASSERT("urn:va:test:6",JSON("data","items",1,"uid")) D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT("gamma",JSON("data","items",6,"name")) + ; test POST query version + K ROOT,JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/index/test-name?query=true","POSTDATA2","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT("gamma",JSON("data","items",6,"name")) Q ORDDESC ;; @TEST query to return in different order N ROOT,JSON,ERR,HTTPERR @@ -52,6 +97,13 @@ D ASSERT("gamma",JSON("data","items",6,"name")) D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT("gamma",JSON("data","items",1,"name")) + ; test POST query version + K ROOT,JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/index/test-name?query=true","POSTDATA3","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT("gamma",JSON("data","items",1,"name")) Q ORDEMPTY ;; @TEST query where 'order by' field contains empty string N ROOT,JSON,ERR,HTTPERR @@ -60,6 +112,13 @@ D ASSERT("gamma",JSON("data","items",1,"name")) D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT("vegatable",JSON("data","items",1,"type")) + ; test POST query version + K ROOT,JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/index/test-name?query=true","POSTDATA4","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT("vegatable",JSON("data","items",1,"type")) Q FILTER ;; @TEST filter to return based on criteria N ROOT,JSON,ERR,HTTPERR @@ -69,6 +128,14 @@ D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(2,JSON("data","totalItems")) D ASSERT("epsilon",JSON("data","items",1,"name")) + ; test POST query version + K ROOT,JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/index/test-name?query=true","POSTDATA5","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(2,JSON("data","totalItems")) + D ASSERT("epsilon",JSON("data","items",1,"name")) Q GETUID ;; @TEST getting an object by UID only N JSON,ERR,HTTPERR @@ -83,8 +150,8 @@ D ASSERT("epsilon",JSON("data","items",1,"name")) D SETGET^VPRJTX("/data/urn:test:bogus:54321") D RESPOND^VPRJRSP D ASSERT(1,$G(HTTPERR)>0) - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code"))) - K ^TMP("HTTPERR",$J) + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code"))) + K ^||TMP("HTTPERR",$J) Q EVERY ;; TEST retrieving every object in a collection N JSON,ERR,HTTPERR @@ -93,7 +160,7 @@ D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code"))) D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(6,JSON("data","totalItems")) - D ASSERT(0,$D(^TMP($J,$J))) + D ASSERT(0,$D(^||TMP($J,$J))) D ASSERT(10,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID_"/every////")))) D ASSERT(0,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID_"/every////"),$J))) K JSON @@ -104,6 +171,15 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(3,JSON("data","currentItemCount")) D ASSERT(10,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID_"/every////")))) D ASSERT(0,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID_"/every////"),$J))) + ; test POST query version + K JSON + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/every?query=true","POSTDATA6","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(3,JSON("data","currentItemCount")) + D ASSERT(10,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID_"/every////")))) + D ASSERT(0,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID_"/every////"),$J))) Q FINDALL ;; @TEST finding every object in collection N JSON,ERR,HTTPERR @@ -121,6 +197,14 @@ D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(2,JSON("data","totalItems")) D ASSERT("urn:va:test:5",JSON("data","items",1,"uid")) + ; test POST query version + K JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/data/find/test?query=true","POSTDATA7","VPRJTDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(2,JSON("data","totalItems")) + D ASSERT("urn:va:test:5",JSON("data","items",1,"uid")) Q FINDTLT ;; @TEST finding with template (applyOnSave) N JSON,ERR,HTTPERR diff --git a/VPRJTDR2.m b/VPRJTDR2.m old mode 100755 new mode 100644 index 2373c80..c4f41f5 --- a/VPRJTDR2.m +++ b/VPRJTDR2.m @@ -56,5 +56,5 @@ D ASSERT("gamma",RSP("data","items",1,"fullItems",2,"name")) D SETGET^VPRJTX("/data/index/bad-index") D RESPOND^VPRJRSP D ASSERT(1,$G(HTTPERR)>0) - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q diff --git a/VPRJTDRN.m b/VPRJTDRN.m new file mode 100644 index 0000000..1083b47 --- /dev/null +++ b/VPRJTDRN.m @@ -0,0 +1,251 @@ +VPRJTDRN ;AFS/MBS -- Unit tests for operational data wrapper code for jdsClient using cache.node + ; +STARTUP ; Run once before all tests + N I,TAGS + F I=1:1:6 S TAGS(I)="TEST"_I_"^VPRJTD01" + D ODSBLD^VPRJTX(.TAGS) + QUIT + ; +SHUTDOWN ; Run once after all tests + D ODSCLR^VPRJTX + QUIT + ; +SETUP ; Run before each test + K ^||TMP + QUIT + ; +TEARDOWN ; Run after each test + K ^||TMP + QUIT + ; +ASSERT(EXPECT,ACTUAL) ; convenience + D EQ^VPRJT(EXPECT,ACTUAL) + QUIT + ; + ; +GETDATAMISSINGUID ;; @TEST get operational data with missing uid + N ERROR,UID,RESULT,UUID + S UID="" + ; + S RESULT=$$GETOBJ^VPRJDRN(UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Bad key",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(104,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETDATABADUID ;; @TEST get operational data with bad uid + N ERROR,UID,RESULT,UUID + ; clear data + D SHUTDOWN + ; + S UID="urn:va:test:3" + ; + S RESULT=$$GETOBJ^VPRJDRN(UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("UID:"_UID,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Bad key",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(104,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETDATABYUID ;; @TEST get operational data by uid + N ERROR,UID,RESULT,UUID + ; retore data + D STARTUP + ; + S UID="urn:va:test:3" + ; + S RESULT=$$GETOBJ^VPRJDRN(UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + ; cleanup + K ^TMP(UUID,$J) + ; + QUIT + ; +GETINDEXMISSINGINDEX ;; @TEST get operational data from index with missing index name + N ERROR,INDEX,RESULT,UUID + S INDEX="" + ; + S RESULT=$$INDEX^VPRJDRN(INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + ; + ; cleanup + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETINDEX ;; @TEST get operational data from index + N ERROR,INDEX,RESULT,UUID + S INDEX="test-name" + ; + S RESULT=$$INDEX^VPRJDRN(INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,1,1))) + D ASSERT(1,$D(^TMP(UUID,$J,2,1))) + D ASSERT(1,$D(^TMP(UUID,$J,3,1))) + D ASSERT(1,$D(^TMP(UUID,$J,4,1))) + D ASSERT(1,$D(^TMP(UUID,$J,5,1))) + D ASSERT(0,$D(^TMP(UUID,$J,6,1))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + ; cleanup + K ^TMP(UUID,$J) + ; + QUIT + ; +GETCOUNTMISSINGCOUNT ;; @TEST get operational data count with missing count name + N ERROR,COUNT,RESULT,UUID + S COUNT="" + ; + S RESULT=$$COUNT^VPRJDRN(COUNT) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + ; + ; cleanup + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETCOUNT ;; @TEST get operational data count + N ERROR,COUNT,RESULT,UUID + S COUNT="collection" + ; + S RESULT=$$COUNT^VPRJDRN(COUNT) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,1))) + D ASSERT(0,$D(^TMP(UUID,$J,2))) + ; + ; cleanup + K ^TMP(UUID,$J) + ; + QUIT + ; +GETALLCOUNTMISSINGCOUNT ;; @TEST get operational data all count with missing count name + N ERROR,COUNT,ALL,RESULT,UUID + S COUNT="",ALL="true" + ; + S RESULT=$$COUNT^VPRJDRN(COUNT,ALL) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + ; + ; cleanup + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETALLCOUNT ;; @TEST get operational data all count + N ERROR,COUNT,ALL,RESULT,UUID + S COUNT="collection",ALL="true" + ; + S RESULT=$$COUNT^VPRJDRN(COUNT,ALL) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,1))) + D ASSERT(0,$D(^TMP(UUID,$J,2))) + ; + ; cleanup + K ^TMP(UUID,$J) + ; + QUIT + ; +FINDMISSINGCOLL ;; @TEST operational data find with missing collection + N ERROR,INDEX,RESULT,UUID + S INDEX="" + ; + S RESULT=$$INDEX^VPRJDRN(INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + ; + ; cleanup + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +FIND ;; @TEST get operational data find + N ERROR,INDEX,RESULT,UUID + S INDEX="test-name" + ; + S RESULT=$$INDEX^VPRJDRN(INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,1,1))) + D ASSERT(1,$D(^TMP(UUID,$J,2,1))) + D ASSERT(1,$D(^TMP(UUID,$J,3,1))) + D ASSERT(1,$D(^TMP(UUID,$J,4,1))) + D ASSERT(1,$D(^TMP(UUID,$J,5,1))) + D ASSERT(0,$D(^TMP(UUID,$J,6,1))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + ; cleanup + K ^TMP(UUID,$J) + ; + QUIT + ; diff --git a/VPRJTDS.m b/VPRJTDS.m old mode 100755 new mode 100644 index 470f885..79ab9b0 --- a/VPRJTDS.m +++ b/VPRJTDS.m @@ -27,8 +27,8 @@ D ASSERT(1,^VPRJDX("count","collection","test")) Q GETOBJ ;; @TEST getting an object D QKEY^VPRJDQ("urn:va:test:1") - D ASSERT(1,$D(^TMP($J,"data",0,"urn:va:test:1",0))) - D ASSERT(1,$G(^TMP($J,"total"))) + D ASSERT(1,$D(^||TMP($J,"data",0,"urn:va:test:1",0))) + D ASSERT(1,$G(^||TMP($J,"total"))) Q DELOBJ ;; @TEST deletion of object D DELETE^VPRJDS("urn:va:test:1") diff --git a/VPRJTERR.m b/VPRJTERR.m deleted file mode 100644 index 10fc897..0000000 --- a/VPRJTERR.m +++ /dev/null @@ -1,542 +0,0 @@ -VPRJTERR ;KRM/CJE -- Unit Tests for GET/PUT/DELETE Error Data - ;;1.0;JSON DATA STORE;;Jan 27, 2015 - ; - ; Endpoints tested - ;POST/PUT error/set/this SET^VPRJERR - ;GET error/get/{id} GET^VPRJERR - ;GET error/length/this LEN^VPRJERR - ;DELETE error/destroy/{id} DEL^VPRJERR - ;GET error/destroy/{id} DEL^VPRJERR - ;DELETE error/clear/this CLR^VPRJERR - ;GET error/clear/this CLR^VPRJERRSET - ; -STARTUP ; Run once before all tests - K ^VPRJERR - S HTTPREQ("store")="error" - Q -SHUTDOWN ; Run once after all tests - K ^VPRJERR - K HTTPREQ - Q -ASSERT(EXPECT,ACTUAL,MSG) ; for convenience - D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) - Q - ; -MOCKDATA(RESULT,JOBID,TIMESTAMP,TYPE,ERROR) ; Mock data for test use - N OBJECT,JSON,ERR - ; Sample JSON - ;{"21797","eff780ca-70d9-4e4f-9984-fcd0f8ac2946",{"pid","9E7A;3"},"21797","error","1432037853138","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A"} - ; - S OBJECT("jobId")=JOBID - S OBJECT("jpid")="eff780ca-70d9-4e4f-9984-fcd0f8ac2946" - S OBJECT("patientIdentifier","type")="pid" - S OBJECT("patientIdentifier","value")="9E7A;3" - S OBJECT("rootJobId")="21797" - S OBJECT("status")="error" - S OBJECT("timestamp")=TIMESTAMP - S OBJECT("type")=TYPE - S OBJECT("error")=ERROR - D ENCODE^VPRJSON("OBJECT","JSON","ERR") - M RESULT=JSON - Q - ; -SETJSON ;; @TEST Put/Post data happy path - N RETURN,BODY,ARG,HTTPERR,ERR,OBJECT,JSON,ERRNUM,ERRMSG - ; - ; Generate Mock Data to be sent to endpoint to store - D MOCKDATA(.JSON,"21797","1432037853138","jmeadows-sync-request","Unable to communicate with Primary VistA instance 9E7A") - ; - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; - ; Send data to the URL - S RETURN=$$SET^VPRJERR(.ARG,.JSON) - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should not occur") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should not occur") - D ASSERT(21797,$G(^VPRJERR(1,"jobId")),"JobId not stored") - D ASSERT(1432037853138,$G(^VPRJERR(1,"timestamp")),"timestamp not stored") - D ASSERT(1,$G(^VPRJERR(1,"id")),"generated id not stored") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q - ; -SETJSONERR ;; @TEST Error code is set if JSON is mangled in PUT/POST - N RETURN,BODY,ARG,HTTPERR,ERR,ERRNUM,ERRMSG,ERRPRE,RESULT - ; Create bad JSON - D MOCKDATA(.BODY,"21797","1432037853138","jmeadows-sync-request","Unable to communicate with primary VistA") - S BODY(3)=BODY(3)_":" - ; Send it to the URL - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D ASSERT(1,$G(^VPRJERR(0)),"More data exists in Error storage and it should not") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q -DELIDERR ;; @TEST Error code is set if no Id - N ARG,ARGS,BODY,DATA,ERR,ERRNUM,ERRMSG,ERRPRE,HTTPERR,OBJECT,RESULT,RETURN - ; Ensure that VPRJERR is cleaned up - K ^VPRJERR - ; Try with a non existant _id - D DEL^VPRJERR(.DATA,.ARGS) - D ASSERT(0,$D(^VPRJERR("0")),"Data exists in Store Error and it should not") - D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup vars - K DATA,OBJECT,ERR,ARGS - ; Try with a blank _id - S ARGS("_id")="" - D DEL^VPRJERR(.DATA,.ARGS) - D ASSERT(0,$D(^VPRJERR("0")),"Data exists in Store Error and it should not") - D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q -DEL ;; @TEST Delete Store Data - N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR - ; Create Store Data - D MOCKDATA(.BODY,"21797","1432037853138","jmeadows-sync-request","Unable to communicate with primary VistA") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - ; Populate ID that is undefined in Error Store - D ASSERT(10,$D(^VPRJERR(1)),"Data in Error Store does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") - D ASSERT(1,$G(^VPRJERR(1,"id")),"The id field was not stored correctly") - D ASSERT("1432037853138",$G(^VPRJERR(1,"timestamp")),"The timestamp field was not stored correctly") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K BODY,RETURN,ARG - ; Now delete it - S ARGS("id")=1 - D DEL^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^VPRJERR(1)),"Store Data exists and it should not") - D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") - ; - K ^TMP("HTTPERR",$J) - Q -LEN ;; @TEST Get number of Store Data - N ARG,ARGS,BODY,DATA,ERR,ERRNUM,ERRMSG,ERRPRE,HTTPERR,ID,OBJECT,RESULT,RETURN - D CLR^VPRJERR - ; Create Store Data - D MOCKDATA(.BODY,"21797","1432037853138","jmeadows-sync-request","Unable to communicate with primary VistA") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D ASSERT(10,$D(^VPRJERR(1)),"A Data in Error Store does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") - D ASSERT(1,$G(^VPRJERR(1,"id")),"The id field was not stored correctly") - D ASSERT("1432037853138",$G(^VPRJERR(1,"timestamp")),"The timestamp field was not stored correctly") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K BODY,RETURN,ARG - ; Now get length - D LEN^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(1,$G(OBJECT("length")),"The total number of objects doesn't match - 1") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K OBJECT,DATA,ERR,ARGS - ; Create Store Data - D MOCKDATA(.BODY,"21797","1432037853139","jmeadows-sync-request","Unable to communicate with primary VistA") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D ASSERT(10,$D(^VPRJERR(2)),"A Data in Error Store does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") - D ASSERT(2,$G(^VPRJERR(2,"id")),"The id field was not stored correctly") - D ASSERT("1432037853139",$G(^VPRJERR(2,"timestamp")),"The timestamp field was not stored correctly") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K BODY,RETURN,ARG - ; Now get length - D LEN^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(2,$G(OBJECT("length")),"The total number of objects doesn't match - 2") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup ^VPRJERR - K ^VPRJERR - Q -GETIDERR ;; @TEST Error code is not set if no Id - N ARG,ARGS,BODY,DATA,ERR,ERRNUM,ERRMSG,ERRPRE,HTTPERR,ID,OBJECT,RESULT,RETURN - ; Try with a non existant id attribute - D GET^VPRJERR(.DATA,.ARGS) - D ASSERT(1,$D(DATA),"DATA should be returned") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP error should not have occured") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K DATA,OBJECT,ARGS - ; Try with a null id - S ARGS("id")="" - D GET^VPRJERR(.DATA,.ARGS) - D ASSERT(1,$D(DATA),"DATA should be returned") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP error should not have occured") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q -GET ;; @TEST Get Store Data - N ARG,ARGS,BODY,DATA,ERR,HTTPERR,ID,OBJECT,RESULT,RETURN - ; Create Store Data - D MOCKDATA(.BODY,"21797","1432037853140","jmeadows-sync-request","Unable to communicate with primary VistA") - ; - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Send it to the URL - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - ; - D ASSERT(10,$D(^VPRJERR(1)),"Data in Error Store does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(^VPRJERR(1,"jobId")),"The jobId field was not stored correctly") - D ASSERT(1432037853140,$G(^VPRJERR(1,"timestamp")),"The timestamp field was not stored correctly") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K RETURN,ARG,BODY - ; Get the data we stored - S ARGS("id")=1 - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(10,$D(^VPRJERR(1)),"Data in Error Store does not exist and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong id") - D ASSERT(1432037853140,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,BODY - ; Create Store Data update - D MOCKDATA(.BODY,"21797","1432037853141","jmeadows-sync-request","Unable to communicate with primary VistA") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D ASSERT(10,$D(^VPRJERR(2)),"Data in Error Store does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(2,$G(^VPRJERR(2,"id")),"The id field was not stored correctly") - D ASSERT(1432037853141,$G(^VPRJERR(2,"timestamp")),"The timestamp field was not stored correctly") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN - ; Get the data we stored update - S ARGS("id")=2 - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(10,$D(^VPRJERR(2)),"Data in Error Store does not exist and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853141,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR - ; Create second Store Data - D MOCKDATA(.BODY,"21797","1432037853141","hdr-sync-request","Unable to communicate with primary VistA") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D ASSERT(10,$D(^VPRJERR(3)),"Data in Error Store does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(^VPRJERR(3,"jobId")),"The id field was not stored correctly") - D ASSERT(1432037853141,$G(^VPRJERR(3,"timestamp")),"The timestamp field was not stored correctly") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN - ; Get second Store Data - S ARGS("id")=3 - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(10,$D(^VPRJERR(3)),"Store Data does not exists and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853141,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; leave these around so they can be killed in the next test - Q -GETFLTR ;; @TEST Get objects by filter - N ARG,ARGS,BODY,DATA,ERR,HTTPERR,ID,OBJECT,RESULT,RETURN - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN,OBJECT - ; Get using filter. there should be two results - S ARGS("filter")="eq(""timestamp"",""1432037853141"")" - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853141,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - D ASSERT(21797,$G(OBJECT("items",2,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853141,$G(OBJECT("items",2,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("",$G(OBJECT("items",3,"jobId")),"more objects returned than there should be") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN,OBJECT - ; Get using filter. there should be two results - S ARGS("filter")="eq(""type"",""hdr-sync-request"")" - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT("hdr-sync-request",$G(OBJECT("items",1,"type")),"returned data for timestamp didn't match") - D ASSERT("",$G(OBJECT("items",2,"jobId")),"more objects returned than there should be") - Q - ; -GETLIMIT ;; @TEST Get objects with limit, start, and startid - N ARG,ARGS,BODY,DATA,ERR,HTTPERR,ID,OBJECT,RESULT,RETURN - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Empty error store - K ^VPRJERR - ; - ; Add errors to the error store to test limit, start, and startid - D MOCKDATA(.BODY,"21795","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21805","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21806","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21796","1432037853131","enterprise-sync-request","Unable to communicate with Primary VistA instance C877") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21797","1432037853132","vler-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21798","1432037853133","vler-sync-request","Unable to communicate with Primary VistA instance C877") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21807","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21808","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21809","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21810","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21799","1432037853134","jmeadows-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21811","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21812","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21813","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21800","1432037853135","jmeadows-sync-request","Unable to communicate with Primary VistA instance C877") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21814","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21801","1432037853136","hdr-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21815","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21816","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21817","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21818","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21819","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21802","1432037853137","hdr-sync-request","Unable to communicate with Primary VistA instance C877") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21820","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21803","1432037853138","store-record","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21821","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21822","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21823","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21824","1432037853130","enterprise-sync-request","Unable to communicate with Primary VistA instance 9E7A") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - D MOCKDATA(.BODY,"21804","1432037853139","store-record","Unable to communicate with Primary VistA instance C877") - S RETURN=$$SET^VPRJERR(.ARG,.BODY) - ; - ; Delete errors out of error store to properly test startid, start, and limit - S ARGS("id")=2 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=3 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=7 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=8 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=9 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=10 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=12 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=13 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=14 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=16 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=18 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=19 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=20 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=21 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=22 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=24 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=26 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=27 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=28 - D DEL^VPRJERR(.DATA,.ARGS) - S ARGS("id")=29 - D DEL^VPRJERR(.DATA,.ARGS) - ; - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,ARGS,BODY,DATA,RETURN,OBJECT - ; Get using limit - S ARGS("limit")=5 - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21795,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853130,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("enterprise-sync-request",$G(OBJECT("items",1,"type")),"returned data for timestamp didn't match") - D ASSERT(1,$G(OBJECT("items",1,"id")),"returned data for the wrong id") - D ASSERT(21796,$G(OBJECT("items",2,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853131,$G(OBJECT("items",2,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("enterprise-sync-request",$G(OBJECT("items",2,"type")),"returned data for timestamp didn't match") - D ASSERT(4,$G(OBJECT("items",2,"id")),"returned data for the wrong id") - D ASSERT(21797,$G(OBJECT("items",3,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853132,$G(OBJECT("items",3,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("vler-sync-request",$G(OBJECT("items",3,"type")),"returned data for timestamp didn't match") - D ASSERT(5,$G(OBJECT("items",3,"id")),"returned data for the wrong id") - D ASSERT(21798,$G(OBJECT("items",4,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853133,$G(OBJECT("items",4,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("vler-sync-request",$G(OBJECT("items",4,"type")),"returned data for timestamp didn't match") - D ASSERT(6,$G(OBJECT("items",4,"id")),"returned data for the wrong id") - D ASSERT(21799,$G(OBJECT("items",5,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853134,$G(OBJECT("items",5,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("jmeadows-sync-request",$G(OBJECT("items",5,"type")),"returned data for timestamp didn't match") - D ASSERT(11,$G(OBJECT("items",5,"id")),"returned data for the wrong id") - D ASSERT("",$G(OBJECT("items",6,"jobId")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",6,"timestamp")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",6,"type")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",6,"id")),"more objects returned than there should be") - ; - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN,OBJECT - ; Get using start and limit - S ARGS("start")=3 - S ARGS("limit")=3 - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853132,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("vler-sync-request",$G(OBJECT("items",1,"type")),"returned data for timestamp didn't match") - D ASSERT(5,$G(OBJECT("items",1,"id")),"returned data for the wrong id") - D ASSERT(21798,$G(OBJECT("items",2,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853133,$G(OBJECT("items",2,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("vler-sync-request",$G(OBJECT("items",2,"type")),"returned data for timestamp didn't match") - D ASSERT(6,$G(OBJECT("items",2,"id")),"returned data for the wrong id") - D ASSERT(21799,$G(OBJECT("items",3,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853134,$G(OBJECT("items",3,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("jmeadows-sync-request",$G(OBJECT("items",3,"type")),"returned data for timestamp didn't match") - D ASSERT(11,$G(OBJECT("items",3,"id")),"returned data for the wrong id") - D ASSERT("",$G(OBJECT("items",4,"jobId")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",4,"timestamp")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",4,"type")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",4,"id")),"more objects returned than there should be") - ; - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN,OBJECT - ; Get using startid, start, and limit - S ARGS("startid")=15 - S ARGS("start")=2 - S ARGS("limit")=2 - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21801,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853136,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("hdr-sync-request",$G(OBJECT("items",1,"type")),"returned data for timestamp didn't match") - D ASSERT(17,$G(OBJECT("items",1,"id")),"returned data for the wrong id") - D ASSERT(21802,$G(OBJECT("items",2,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853137,$G(OBJECT("items",2,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("hdr-sync-request",$G(OBJECT("items",2,"type")),"returned data for timestamp didn't match") - D ASSERT(23,$G(OBJECT("items",2,"id")),"returned data for the wrong id") - D ASSERT("",$G(OBJECT("items",3,"jobId")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",3,"timestamp")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",3,"type")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",3,"id")),"more objects returned than there should be") - ; - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - ; Cleanup Vars - K ARG,BODY,RETURN,OBJECT - ; Get using startid, start, limit, and filter - S ARGS("startid")=4 - S ARGS("start")=2 - S ARGS("limit")=4 - S ARGS("filter")="or(eq(type,vler-sync-request),eq(type,store-record))" - D GET^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") - D ASSERT(21797,$G(OBJECT("items",1,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853132,$G(OBJECT("items",1,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("vler-sync-request",$G(OBJECT("items",1,"type")),"returned data for timestamp didn't match") - D ASSERT(5,$G(OBJECT("items",1,"id")),"returned data for the wrong id") - D ASSERT(21798,$G(OBJECT("items",2,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853133,$G(OBJECT("items",2,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("vler-sync-request",$G(OBJECT("items",2,"type")),"returned data for timestamp didn't match") - D ASSERT(6,$G(OBJECT("items",2,"id")),"returned data for the wrong id") - D ASSERT(21803,$G(OBJECT("items",3,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853138,$G(OBJECT("items",3,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("store-record",$G(OBJECT("items",3,"type")),"returned data for timestamp didn't match") - D ASSERT(25,$G(OBJECT("items",3,"id")),"returned data for the wrong id") - D ASSERT(21804,$G(OBJECT("items",4,"jobId")),"returned data for the wrong jobId") - D ASSERT(1432037853139,$G(OBJECT("items",4,"timestamp")),"returned data for timestamp didn't match") - D ASSERT("store-record",$G(OBJECT("items",4,"type")),"returned data for timestamp didn't match") - D ASSERT(30,$G(OBJECT("items",4,"id")),"returned data for the wrong id") - D ASSERT("",$G(OBJECT("items",5,"jobId")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",5,"timestamp")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",5,"type")),"more objects returned than there should be") - D ASSERT("",$G(OBJECT("items",5,"id")),"more objects returned than there should be") - Q - ; -CLR ;; @TEST Clear ALL Store Data - N ARG,ARGS,BODY,DATA,ERR,ERRNUM,ERRMSG,ERRPRE,HTTPERR,OBJECT,RESULT,RETURN - D CLR^VPRJERR(.DATA,.ARGS) - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^VPRJERR("2")),"Data exists in Store Error and it should not") - D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") - D ASSERT(10,$D(^VPRJERR),"Global not cleared") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q - ; diff --git a/VPRJTGC.m b/VPRJTGC.m old mode 100755 new mode 100644 index 102c7a0..18a1f43 --- a/VPRJTGC.m +++ b/VPRJTGC.m @@ -252,7 +252,7 @@ D MOCKSSD(UID,METASTAMP1) ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure previous version of object is gone D ASSERT(0,$D(^VPRPT(JPID,PID,UID,METASTAMP1)),"Previous medication ARRAY version found and it shouldn't be found") D ASSERT(10,$D(^VPRPT(JPID,PID,UID,METASTAMP2)),"Current medication ARRAY version not found and it should be found") @@ -281,7 +281,7 @@ D ASSERT(1,$G(^VPRPTJ("TEMPLATE",JPID,PID,UID,"dose",1))["""dose"":""70 MG""","C ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure previous version of object is gone D ASSERT(0,$D(^VPRPT(JPID,PID,UID,METASTAMP1)),"Previous medication ARRAY version found and it shouldn't be found") D ASSERT(10,$D(^VPRPT(JPID,PID,UID,METASTAMP2)),"Current medication ARRAY version not found and it should be found") @@ -309,7 +309,7 @@ D ASSERT(1,$G(^VPRPTJ("TEMPLATE",JPID,PID,UID,"dose",1))["""dose"":""70 MG""","C ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") F PID="93EF;-7","93EF;-8" D . S PID2=$TR(PID,";",":") . S UID="urn:va:med:"_PID2_":15231" @@ -340,7 +340,7 @@ D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") F PID="93EF;-7","93EF;-8" D . S PID2=$TR(PID,";",":") . S UID="urn:va:med:"_PID2_":15231" @@ -371,7 +371,7 @@ D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure previous version of object is gone D ASSERT(0,$D(^VPRJD(UID,METASTAMP1)),"Previous test ARRAY version found and it shouldn't be found") D ASSERT(10,$D(^VPRJD(UID,METASTAMP2)),"Current test ARRAY version not found and it should be found") @@ -396,7 +396,7 @@ D ASSERT(1,$G(^VPRJDJ("TEMPLATE",UID,"unit-test-ods-summary",1))["""name"":""ome ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure previous version of object is gone D ASSERT(0,$D(^VPRJD(UID,METASTAMP1)),"Previous test ARRAY version found and it shouldn't be found") D ASSERT(10,$D(^VPRJD(UID,METASTAMP2)),"Current test ARRAY version not found and it should be found") @@ -421,7 +421,7 @@ D ASSERT(1,$G(^VPRJDJ("TEMPLATE",UID,"unit-test-ods-summary",1))["""name"":""ome ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") F SITE="F111","F112" D . S UID="urn:va:test:"_SITE_":4" . ; Ensure previous version of object is gone @@ -448,7 +448,7 @@ D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") F SITE="F111","F112" D . S UID="urn:va:test:"_SITE_":4" . ; Ensure previous version of object is gone @@ -522,7 +522,7 @@ D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure that the correct jobs remain, and the correct jobs are gone ; ^VPRJOB(Sequential counter)=Passed JSON Object D ASSERT(0,$D(^VPRJOB(1)),"Earlier job ARRAY found and it should not be found") @@ -645,7 +645,7 @@ D ASSERT(1,$D(^VPRJOB("D",JPID,"jmeadows-lab-sync-request",201412180711208,9))," ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure that the correct jobs remain, and the correct jobs are gone ; ^VPRJOB(Sequential counter)=Passed JSON Object D ASSERT(0,$D(^VPRJOB(1)),"Earlier job ARRAY found and it should not be found") @@ -865,7 +865,7 @@ D ASSERT(1,$D(^VPRJOB("D",JPID,"jmeadows-lab-sync-request",201412180711217,18)), ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure that the correct jobs remain, and the correct jobs are gone ; ^VPRJOB(Sequential counter)=Passed JSON Object D ASSERT(0,$D(^VPRJOB(1)),"Earlier job ARRAY found and it should not be found") @@ -1094,7 +1094,7 @@ D ASSERT(1,$D(^VPRJOB("D",JPID,"jmeadows-lab-sync-request",201412180711217,18)), ; Wait for job to finish H 1 ; Ensure HTTP Request had no errors - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error during HTTP rquest") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error during HTTP rquest") ; Ensure that the correct jobs remain, and the correct jobs are gone ; ^VPRJOB(Sequential counter)=Passed JSON Object D ASSERT(0,$D(^VPRJOB(1)),"Earlier job ARRAY found and it should not be found") diff --git a/VPRJTGDS.m b/VPRJTGDS.m index 3ff4c20..1311357 100644 --- a/VPRJTGDS.m +++ b/VPRJTGDS.m @@ -1,5 +1,4 @@ VPRJTGDS ;KRM/CJE -- Unit Tests for CRUD operations for Generic Data Stores - ;;1.0;JSON DATA STORE;;Jan 27, 2015 ; ; Endpoints tested ; GET /{uid} GET^VPRJGDS @@ -9,13 +8,18 @@ ; POST SET^VPRJGDS ; POST /index CINDEX^VPRJGDS ; GET /index/{indexName} INDEX^VPRJGDS + ; POST /template CTEMPLATE^VPRJGDS + ; GET /index/{indexName}/{template} INDEX^VPRJGDS + ; GET /lock + ; PUT /lock/{uid} + ; DELETE /lock/{uid} ; DELETE CLR^VPRJGDS Q STARTUP ; Run once before all tests ; ensure that we have a store for the unit tests N HTTPREQ,HTTPERR D ADDSTORE^VPRJCONFIG("ut") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SHUTDOWN ; Run once after all tests ; DELETE database test will remove the store from the database and route map @@ -23,8 +27,8 @@ K ^VPRMETA("collection","ut"),^VPRMETA("index","gdsutest"),^VPRMETA("index","gdsutest2"),^VPRMETA("index","gdsutest3") Q TEARDOWN ; Run after each test - K ^TMP($J) - K ^TMP("HTTPERR",$J) + K ^||TMP($J) + K ^||TMP("HTTPERR",$J) Q ASSERT(EXPECT,ACTUAL,MSG) ; for convenience D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) @@ -41,25 +45,62 @@ Q:$G(SORT)="null" "{""indexName"": """_NAME_""",""fields"": """_FIELDS_""",""type"": """_TYPE_"""}" Q:$G(TYPE)="null" "{""indexName"": """_NAME_""",""fields"": """_FIELDS_""",""sort"": """_SORT_"""}" Q "{""indexName"": """_NAME_""",""fields"": """_FIELDS_""",""sort"": """_SORT_""",""type"": """_TYPE_"""}" + ; + ; Setup Template data JSON for Create Template +SAMPLETEMPLATE(NAME,DIRECTIVES,FIELDS) + Q:$G(NAME)="null" "{""fields"": """_FIELDS_""",""directives"": """_DIRECTIVES_"""}" + Q:$G(FIELDS)="null" "{""name"": """_NAME_""",""directives"": """_DIRECTIVES_"""}" + Q:$G(DIRECTIVES)="null" "{""name"": """_NAME_""",""fields"": """_FIELDS_"""}" + Q "{""name"": """_NAME_""",""fields"": """_FIELDS_""",""directives"": """_DIRECTIVES_"""}" + ; + ; Parse return type=3 responses (paged responses) + ; @param {array} RAW - (passed by reference) RAW response + ; @param {array} PARSED - (passed by reference) M array representation of JSON + ; @param {string} PARSE - boolean to control parsing of data +PARSE(RAW,PARSED,PARSE) + ; Assumes HTTPREQ is newed by caller + ; + ; QUIT early if there is nothing to do + I '$D(RAW) QUIT + ; + N START,LIMIT,SIZE,PREAMBLE,RSP,DATA,I,J,RETCNTS + S PARSE=$G(PARSE,1) + ; Setup paging info for PAGE^VPRJRUT + S HTTPREQ("paging")=$G(ARGS("start"),0)_":"_$G(ARGS("limit"),999999) + S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2),STARTID=$G(RAW("startid")) + S RETCNTS=$S($G(RAW("returncounts"))="true":1,1:0) + I STARTID'="" F I=1:1:$G(@RAW@("total")) I $D(@RAW@("data",I,STARTID)) S START=START+I Q + D PAGE^VPRJRUT(.RAW,START,LIMIT,.SIZE,.PREAMBLE,RETCNTS) + ; Emulate RESPOND^VPRJRSP to get a real JSON response + S DATA(0)=PREAMBLE + F I=START:1:(START+LIMIT-1) Q:'$D(@RAW@($J,I)) D + . I I>START S DATA(I)="," ; separate items with a comma + . S J="" F S J=$O(@RAW@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RAW@($J,I,J) + S DATA(I)=$G(DATA(I))_"]}" + D:$D(DATA)&PARSE DECODE^VPRJSON("DATA","PARSED","ERR") + D:PARSE ASSERT(0,$D(ERR),"ERROR Decoding JSON (IN PARSE^VPRJTGDS)") + M:'PARSE PARSED=DATA + QUIT + ; ; Begin Test Suite ; SETNOSTORE ;; @TEST Error code is set if no store in HTTPREQ N RETURN,BODY,ARG,HTTPERR ; Create sample JSON - S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:9E7A:10000000265") + S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:SITE:10000000265") ; Send it to the URL S RETURN=$$SET^VPRJGDS(.ARG,.BODY) - D ASSERT(0,$D(^VPRJUT("urn:va:user:9E7A:10000000265")),"Data stored when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(0,$D(^VPRJUT("urn:va:user:SITE:10000000265")),"Data stored when it shouldn't be") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; SETNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG N RETURN,BODY,ARG,HTTPERR,GLOBALSAVE ; Create sample JSON - S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:9E7A:10000000265") + S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:SITE:10000000265") ; Kill off the global area for the test S GLOBALSAVE=^VPRCONFIG("store","ut","global") K ^VPRCONFIG("store","ut","global") @@ -67,11 +108,11 @@ S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:9E7A:10000000265") S HTTPREQ("store")="ut" S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") - D ASSERT(0,$D(^VPRJUT("urn:va:user:9E7A:10000000265")),"Data stored when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(0,$D(^VPRJUT("urn:va:user:SITE:10000000265")),"Data stored when it shouldn't be") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Restore the global area for the rest of the tests S ^VPRCONFIG("store","ut","global")=GLOBALSAVE Q @@ -81,24 +122,24 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason ; Send it to the URL S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUT),"Data stored when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(255,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 255 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(255,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 255 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; SETJSONERR ;; @TEST Error code is set if JSON is mangled in PUT/POST N RETURN,BODY,ARG,HTTPERR ; Create bad JSON - S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:9E7A:10000000265") + S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:user:SITE:10000000265") S BODY(1)=BODY(1)_":" ; Send it to the URL S RETURN=$$SET^VPRJGDS(.ARG,.BODY) - D ASSERT(0,$D(^VPRJUT("urn:va:user:9E7A:10000000265")),"Data stored when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + D ASSERT(0,$D(^VPRJUT("urn:va:user:SITE:10000000265")),"Data stored when it shouldn't be") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; SETNOUID ;; @TEST POST with no UID @@ -107,25 +148,25 @@ D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)))),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:"_$G(^VPRJUT(0)),$G(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)),"uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)),"lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:"_$G(^VPRJUT(0)),"The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG - ; Try with a non existant uid field + ; Try with a non existent uid field ; "null" is a magic string to the SAMPLEDATA generator to prevent the uid field from even being passed S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","null") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)))),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:"_$G(^VPRJUT(0)),$G(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)),"uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)),"lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:"_$G(^VPRJUT(0)),"The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; SET1 ;; @TEST PUT with UID @@ -133,12 +174,12 @@ D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:"_$G(^VPRJUT(0)),"The UID wasn't returned" S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:ut:23") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:23")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:23",$G(^VPRJUT("urn:va:ut:23","uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:23","lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:23","The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; SET2 ;; @TEST PUTing 2 items with UID @@ -146,41 +187,41 @@ D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:23","The UID wasn't returned") S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:ut:23") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:23")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:23",$G(^VPRJUT("urn:va:ut:23","uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:23","lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT("ehmp-proxy",$G(^VPRJUT("urn:va:ut:23","roles",1)),"The roles array (1) was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:23","The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Update the record S BODY(1)=$$SAMPLEDATA("""ehmp-proxy"",""ehmp-test""","urn:va:ut:23") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:23")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:23",$G(^VPRJUT("urn:va:ut:23","uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:23","lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT("ehmp-proxy",$G(^VPRJUT("urn:va:ut:23","roles",1)),"The roles array (1) was not stored correctly") D ASSERT("ehmp-test",$G(^VPRJUT("urn:va:ut:23","roles",2)),"The roles array (2) was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:23","The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Add a second one S BODY(1)=$$SAMPLEDATA("""ehmp-proxy"",""ehmp-test""","urn:va:ut:5") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:5")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:5",$G(^VPRJUT("urn:va:ut:5","uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:5","lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT("ehmp-proxy",$G(^VPRJUT("urn:va:ut:5","roles",1)),"The roles array (1) was not stored correctly") D ASSERT("ehmp-test",$G(^VPRJUT("urn:va:ut:5","roles",2)),"The roles array (2) was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:5","The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETCOLLISION ;; cause a collision and ensure everything works as intended Q @@ -191,10 +232,10 @@ D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:5","The UID wasn't returned") ; Send it to the URL K HTTPREQ("store") D DEL^VPRJGDS(.DATA,.ARGS) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; DELNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG @@ -206,33 +247,33 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason S HTTPREQ("store")="ut" D DEL^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Restore the global area for the rest of the tests S ^VPRCONFIG("store","ut","global")=GLOBALSAVE Q ; DELIDERR ;; @TEST Error code is set if no uid N DATA,OBJECT,ERR,ARGS,HTTPERR - ; Try with a non existant uid + ; Try with a non existent uid D DEL^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup vars K DATA,OBJECT,ERR,ARGS ; Try with a blank uid S ARGS("uid")="" D DEL^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; DEL ;; @TEST Delete Data @@ -243,9 +284,10 @@ S ARGS("uid")="urn:va:ut:23" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(0,$D(^VPRJUT("urn:va:ut:23")),"Data exists and it should not") D ASSERT(0,$D(^VPRJUTJ("JSON","urn:va:ut:23")),"Data exists and it should not") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:23")),"Data exists and it should not") D ASSERT("{""ok"": true}",$G(DATA),"DATA returned from a DELETE call (should not happen)") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; ; @@ -254,10 +296,10 @@ D ASSERT("{""ok"": true}",$G(DATA),"DATA returned from a DELETE call (should not ; Send it to the URL K HTTPREQ("store") D INFO^VPRJGDS(.DATA,.ARGS) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; INFONOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG @@ -269,10 +311,10 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason S HTTPREQ("store")="ut" D INFO^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Restore the global area for the rest of the tests S ^VPRCONFIG("store","ut","global")=GLOBALSAVE Q @@ -282,7 +324,7 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason ; GET the database info D INFO^VPRJGDS(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error Occured") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") ; only test the info that is supported D ASSERT("ut",$G(OBJECT("db_name")),"The db_name doesn't match") @@ -291,30 +333,30 @@ D ASSERT(1,$D(OBJECT("doc_count")),"The doc_count doesn't match") ; save off the count so we can prove it works S COUNT=$G(OBJECT("doc_count")) ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K OBJECT,DATA,ERR,ARGS ; Create more data to test count S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)))),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:"_$G(^VPRJUT(0)),$G(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)),"uid")),"The uid field was not stored correctly") D ASSERT("20130526050000000",$G(^VPRJUT("urn:va:ut:"_$G(^VPRJUT(0)),"lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:"_$G(^VPRJUT(0)),"The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now get the database info, we only have to test count D INFO^VPRJGDS(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error Occured") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") ; ensure the count is one more than last time D ASSERT(COUNT+1,$G(OBJECT("doc_count")),"The doc_count doesn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; ; @@ -323,10 +365,10 @@ D ASSERT(COUNT+1,$G(OBJECT("doc_count")),"The doc_count doesn't match") ; Send it to the URL K HTTPREQ("store") D GET^VPRJGDS(.DATA,.ARGS) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; GETNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG @@ -338,49 +380,78 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason S HTTPREQ("store")="ut" D GET^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Restore the global area for the rest of the tests S ^VPRCONFIG("store","ut","global")=GLOBALSAVE Q ; GETNOID ;; @TEST Data is returned if no uid passed N DATA,ARGS,OBJECT,HTTPERR - ; Try with a non existant uid attribute + ; Try with a non existent uid attribute D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(1,$D(DATA),"DATA should be returned") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT(0,$D(OBJECT("totalItems")),"totalItems attribute returned, and it should not be") + D ASSERT(0,$D(OBJECT("currentItemCount")),"currentItemCount attribute returned, and it should not be") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,OBJECT,ARGS,ERR ; Try with a null uid S ARGS("uid")="" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(1,$D(DATA),"DATA should be returned") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q + K ^||TMP("HTTPERR",$J) + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K DATA,OBJECT,ARGS,ERR + ; + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Need to pass this in to DATA directly, because RESPOND^VPRJRSP is not run here + ; Try with counts returned + S DATA("returncounts")="true" + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT(1,$D(OBJECT("totalItems")),"totalItems attribute not returned") + D ASSERT($O(OBJECT("items",""),-1),$G(OBJECT("totalItems")),"totalItems attribute did not match total items returned") + D ASSERT(1,$D(OBJECT("currentItemCount")),"currentItemCount attribute not returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT ; GETUIDUNK ;; @TEST Error code if uid doesn't exist N DATA,ARGS,OBJECT,HTTPERR - ; Try with a non existant uid attribute + ; Try with a non existent uid attribute S ARGS("uid")="urn:va:ut:1337" D GET^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(229,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 229 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(229,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 229 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; GET ;; @TEST Get Single object @@ -388,29 +459,66 @@ D ASSERT(229,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 229 reason ; Get the data we've stored so far S ARGS("uid")="urn:va:ut:7" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") + D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJUT("urn:va:ut:7")),"Data does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:7",$G(OBJECT("uid")),"The uid field was not returned correctly") D ASSERT("20130526050000000",$G(OBJECT("lastLogin","date")),"The lastLogin.date attribute was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR ; Get another object S ARGS("uid")="urn:va:ut:5" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") + D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJUT("urn:va:ut:5")),"Data does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:5",$G(OBJECT("uid")),"The uid field was not returned correctly") D ASSERT("20130526050000000",$G(OBJECT("lastLogin","date")),"The lastLogin.date attribute was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("roles",1)),"The roles array (1) was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("roles",2)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) + QUIT + ; +GETSTARTID ;; @TEST Get objects beginning with a selected id + N RETURN,ARGS,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR + S ARGS("startid")="urn:va:ut:2" + D GET^VPRJGDS(.DATA,.ARGS) + D PARSE(.DATA,.OBJECT) + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:2",$G(OBJECT("items",1,"uid")),"Returned list should have started with urn:va:ut:2") + D ASSERT("urn:va:ut:7",$G(OBJECT("items",3,"uid")),"urn:va:ut:7 should have been third item in list") + K ^||TMP("HTTPERR",$J),@DATA + QUIT + ; +GETSTART ;; @TEST Get objects beginning at an offset + N RETURN,ARGS,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR + S ARGS("start")="2" + D GET^VPRJGDS(.DATA,.ARGS) + D PARSE(.DATA,.OBJECT) + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:5",$G(OBJECT("items",1,"uid")),"Returned list should have started with urn:va:ut:2") + D ASSERT("",$G(OBJECT("items",3,"uid")),"There should not have been a third item in the list") + K ^||TMP("HTTPERR",$J),@DATA + Q + ; +GETLIMIT ;; @TEST Get objects up to a limit + N RETURN,ARGS,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR + S ARGS("limit")="3" + D GET^VPRJGDS(.DATA,.ARGS) + D PARSE(.DATA,.OBJECT) + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"Returned list should have started with urn:va:ut:1") + D ASSERT("urn:va:ut:5",$G(OBJECT("items",3,"uid")),"urn:va:ut:5 should have been third item in list") + D ASSERT(0,$D(OBJECT("items",4)),"There should not be a fouth item returned") + K ^||TMP("HTTPERR",$J),@DATA Q ; UPDATE ;; @TEST Update a record @@ -419,25 +527,25 @@ D ASSERT("ehmp-test",$G(OBJECT("roles",2)),"The roles array (2) was not returned S BODY(1)=$$SAMPLEDATA("""ehmp-proxy"",""ehmp-test""","urn:va:ut:99") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:99")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:99",$G(^VPRJUT("urn:va:ut:99","uid")),"The uid field was not stored correctly") D ASSERT("ehmp-proxy",$G(^VPRJUT("urn:va:ut:99","roles","1")),"The first role attribute in the array was not stored correctly") D ASSERT("ehmp-test",$G(^VPRJUT("urn:va:ut:99","roles","2")),"The second role attribute in the array was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:99","The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K RETURN,BODY,ARG,HTTPERR ; Store a record with less data S BODY(1)=$$SAMPLEDATA("""ehmp-test""","urn:va:ut:99") S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT("urn:va:ut:99")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:99",$G(^VPRJUT("urn:va:ut:99","uid")),"The uid field was not stored correctly") D ASSERT("ehmp-test",$G(^VPRJUT("urn:va:ut:99","roles","1")),"The first role attribute in the array was not stored correctly") D ASSERT("",$G(^VPRJUT("urn:va:ut:99","roles","2")),"The second role attribute in the array was not stored correctly") D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:99","The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; GETFILTER ;; @TEST Get object with filter @@ -445,21 +553,25 @@ D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:99","The UID wasn't returned") ; Get with eq filter an exact match S ARGS("filter")="eq(""uid"",""urn:va:ut:7"")" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:7",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("20130526050000000",$G(OBJECT("items",1,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR + K @DATA,ARGS,OBJECT,ERR ; Get with eq filter a value in an array S ARGS("filter")="eq(""roles[]"",""ehmp-proxy"")" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") @@ -470,44 +582,50 @@ D ASSERT("ehmp-test",$G(OBJECT("items",3,"roles",2)),"The roles array (2) was no D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles array (1) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR + K @DATA,ARGS,OBJECT,ERR ; Get with eq filter a value in an array (two matches) S ARGS("filter")="eq(""roles[]"",""ehmp-test"")" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:5",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",1,"roles",2)),"The roles array (2) was not returned correctly") D ASSERT("urn:va:ut:99",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",2,"roles",1)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR + K @DATA,ARGS,OBJECT,ERR ; Get with complex filter (only one match) ; This is an implicit and S ARGS("filter")="eq(""roles[]"",""ehmp-test""),eq(""uid"",""urn:va:ut:99"")" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:99",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",1,"roles",1)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR + K @DATA,ARGS,OBJECT,ERR ; Get with complex filter (multiple matches) ; This is an implicit and S ARGS("filter")="or(eq(""roles[]"",""ehmp-proxy""),eq(""uid"",""urn:va:ut:99""))" D GET^VPRJGDS(.DATA,.ARGS) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (2) was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") @@ -519,8 +637,8 @@ D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles array (2) was n D ASSERT("urn:va:ut:99",$G(OBJECT("items",5,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",5,"roles",1)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q + K ^||TMP("HTTPERR",$J) + QUIT ; ; CINDEXNOSTORE ;; @TEST Create Index - Error code is set if no store in HTTPREQ @@ -531,10 +649,10 @@ S BODY(1)=$$SAMPLEINDEX("gdsutest","roles[]","roles asc","attr") ; Send it to the URL S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S HTTPREQ("store")="ut" Q ; @@ -550,10 +668,10 @@ S HTTPREQ("store")="ut" S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Restore the global area for the rest of the tests S ^VPRCONFIG("store","ut","global")=GLOBALSAVE Q @@ -563,10 +681,10 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason ; Send it to the URL S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(255,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 255 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(255,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 255 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; CINDEXJSONERR ;; @TEST Error code is set if JSON is mangled in PUT/POST @@ -577,10 +695,10 @@ S BODY(1)=BODY(1)_":" ; Send it to the URL S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; CINDEXMFIELDS ;; @TEST POST without required fields @@ -589,10 +707,10 @@ D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason S BODY(1)=$$SAMPLEINDEX("","roles[]","roles asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; @@ -600,10 +718,10 @@ D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason S BODY(1)=$$SAMPLEINDEX("gdsutest","","roles asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; @@ -611,10 +729,10 @@ D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason S BODY(1)=$$SAMPLEINDEX("gdsutest","roles[]","","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; @@ -622,10 +740,10 @@ D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason S BODY(1)=$$SAMPLEINDEX("gdsutest","roles[]","roles asc","") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; @@ -633,52 +751,52 @@ D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason S BODY(1)=$$SAMPLEINDEX("","","","") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; - ; Try with a non existant name + ; Try with a non existent name ; "null" is a magic string to the SAMPLEINDEX generator to prevent the field from even being passed S BODY(1)=$$SAMPLEINDEX("null","roles[]","roles asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; - ; Try with a non existant fields + ; Try with a non existent fields ; "null" is a magic string to the SAMPLEINDEX generator to prevent the field from even being passed S BODY(1)=$$SAMPLEINDEX("gdsutest","null","roles asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; - ; Try with a non existant sort + ; Try with a non existent sort ; "null" is a magic string to the SAMPLEINDEX generator to prevent the field from even being passed S BODY(1)=$$SAMPLEINDEX("gdsutest","roles[]","null","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; - ; Try with a non existant type + ; Try with a non existent type ; "null" is a magic string to the SAMPLEINDEX generator to prevent the field from even being passed S BODY(1)=$$SAMPLEINDEX("gdsutest","roles[]","roles asc","null") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(0,$D(^VPRJUTX("attr","gdsutest")),"Index created when it shouldn't be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") - D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; CINDEX1 ;; @TEST Create 1 index (happy path) @@ -686,12 +804,12 @@ D ASSERT(273,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason S BODY(1)=$$SAMPLEINDEX("gdsutest","roles[]","roles asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(11,$D(^VPRJUTX("attr","gdsutest")),"Index NOT created when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT(1,$D(^VPRJUTX("attr","gdsutest","ehmp-proxy ","urn:va:ut:1","roles#1")),"The first role type is not as expected") D ASSERT(1,$D(^VPRJUTX("attr","gdsutest","ehmp-test ","urn:va:ut:5","roles#2")),"The second role type is not as expected") D ASSERT(10,$D(^VPRCONFIG("store","ut","index","gdsutest")),"Index Not stored in VPRJCONFIG") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; CINDEX2 ;; @TEST Creating 2 (additional) indexes @@ -699,24 +817,24 @@ D ASSERT(10,$D(^VPRCONFIG("store","ut","index","gdsutest")),"Index Not stored in S BODY(1)=$$SAMPLEINDEX("gdsutest2","lastLogin.date","date asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(11,$D(^VPRJUTX("attr","gdsutest2")),"Index NOT created when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT(1,$D(^VPRJUTX("attr","gdsutest2","20130526050000000 ","urn:va:ut:1",1)),"The first lastLogin.date index is not as expected") D ASSERT(1,$D(^VPRJUTX("attr","gdsutest2","20130526050000000 ","urn:va:ut:2",1)),"The second lastLogin.date index is not as expected") D ASSERT(10,$D(^VPRCONFIG("store","ut","index","gdsutest2")),"Index Not stored in VPRJCONFIG") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Update the record S BODY(1)=$$SAMPLEINDEX("gdsutest3","createDate.date","date asc","attr") S RETURN=$$CINDEX^VPRJGDS(.ARG,.BODY) D ASSERT(11,$D(^VPRJUTX("attr","gdsutest3")),"Index NOT created when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT(1,$D(^VPRJUTX("attr","gdsutest3","20000101120000000 ","urn:va:ut:1",1)),"The first createDate.date index is not as expected") D ASSERT(1,$D(^VPRJUTX("attr","gdsutest3","20000101120000000 ","urn:va:ut:2",1)),"The second createDate.date index is not as expected") D ASSERT(10,$D(^VPRCONFIG("store","ut","index","gdsutest3")),"Index Not stored in VPRJCONFIG") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; ; @@ -725,10 +843,10 @@ D ASSERT(10,$D(^VPRCONFIG("store","ut","index","gdsutest3")),"Index Not stored i ; Send it to the URL K HTTPREQ("store") D INDEX^VPRJGDS(.DATA,.ARGS) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; INDEXNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG @@ -740,90 +858,151 @@ D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason S HTTPREQ("store")="ut" D INDEX^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(253,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Restore the global area for the rest of the tests S ^VPRCONFIG("store","ut","global")=GLOBALSAVE Q ; INDEXNOINDEX ;; @TEST Error code is set if no index specified N DATA,OBJECT,ERR,ARGS,HTTPERR,GLOBALSAVE - ; Try with non-existant indexName + ; Try with non-existent indexName ; Send it to the URL D INDEX^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(DATA),"DATA returned and there shouldn't be any") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(102,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 102 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(102,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 102 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Try with null indexName ; Send it to the URL S ARGS("indexName")="" D INDEX^VPRJGDS(.DATA,.ARGS) D ASSERT(0,$D(DATA),"DATA returned and there shouldn't be any") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(102,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 102 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(102,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 102 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ; INDEX ;; @TEST Get via Index N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR - N START,LIMIT,SIZE,PREAMBLE,RSP - ; Setup paging info for PAGE^VPRJRUT - S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) - S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2) ; ; Get the data we've stored so far S ARGS("indexName")="gdsutest" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") D ASSERT("urn:va:ut:99",$G(OBJECT("items",5,"uid")),"The uid field was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR,RSP ; Get another object S ARGS("indexName")="gdsutest2" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") D ASSERT("urn:va:ut:99",$G(OBJECT("items",5,"uid")),"The uid field was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K DATA,ARGS,OBJECT,ERR,RSP + ; + ; make sure that returncounts is a recognized query parameter and it returns the data as expected + S (ARGS("returncounts"),RSP("returncounts"))="true" + S ARGS("indexName")="gdsutest2" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(11,$D(RSP),"RSP should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT(1,$D(OBJECT("totalItems")),"totalItems attribute not returned") + D ASSERT($O(OBJECT("items",""),-1),$G(OBJECT("totalItems")),"totalItems attribute did not match total items returned") + D ASSERT(1,$D(OBJECT("currentItemCount")),"currentItemCount attribute not returned") + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) Q ; +INDEXLOCK ;; @TEST Get via Index and a locked record + N RETURN,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,TIMEOUT,RSP + ; + ; Get the data we've stored so far + ; lock uid: urn:va:ut:2 + S ARGS("uid")="urn:va:ut:2" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:2",$G(RETURN),"The returned location header isn't as expected") + K ARGS,BODY,RETURN + ; + S ARGS("indexName")="gdsutest" + S ARGS("skiplocked")="true" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("urn:va:ut:5",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") + D ASSERT("urn:va:ut:99",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT(0,$D(OBJECT("items",5)),"Too many items were returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K DATA,ARGS,OBJECT,ERR,RSP + K ^||TMP($J) + ; + ; expire the lock + ; Set the timeout value to something smaller so the tests don't take forever + S TIMEOUT=$G(^VPRCONFIG("store","ut","lockTimeout")) + S ^VPRCONFIG("store","ut","lockTimeout")=1 + H 2 + S ARGS("indexName")="gdsutest" + S ARGS("skiplocked")="true" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") + D ASSERT("urn:va:ut:99",$G(OBJECT("items",5,"uid")),"The uid field was not returned correctly") + D ASSERT(0,$D(OBJECT("items",6)),"Too many items were returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Remove the lock + K ^VPRJUTL("urn:va:ut:2") + ; Restore the timeout value + S ^VPRCONFIG("store","ut","lockTimeout")=TIMEOUT + QUIT + ; DELETEITEMINDEX ;; @TEST deleted item isn't in Index N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR - N START,LIMIT,SIZE,PREAMBLE,RSP - ; Setup paging info for PAGE^VPRJRUT - S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) - S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2) ; ; delete an object S ARGS("uid")="urn:va:ut:99" @@ -832,22 +1011,17 @@ S ARGS("uid")="urn:va:ut:99" ; Get the data we've stored so far S ARGS("indexName")="gdsutest" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") D ASSERT("",$G(OBJECT("items",5,"uid")),"Object 99 exists and shouldn't") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K BODY,RETURN,ARG ; RE-add uid urn:va:ut:99 S BODY(1)=$$SAMPLEDATA("""ehmp-test""","urn:va:ut:99") @@ -856,47 +1030,32 @@ S BODY(1)=$$SAMPLEDATA("""ehmp-test""","urn:va:ut:99") ; INDEXFILTER ;; @TEST Get index with filter N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,I,J - N START,LIMIT,SIZE,PREAMBLE,RSP - ; Setup paging info for PAGE^VPRJRUT - S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) - S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2) - K ^TMP($J) ; ; Get Index with eq filter for an exact match S ARGS("indexName")="gdsutest" S ARGS("filter")="eq(""uid"",""urn:va:ut:7"")" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:7",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("20130526050000000",$G(OBJECT("items",1,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,I,J,RSP + K ARGS,OBJECT,RSP ; Get Index with eq filter a value in an array S ARGS("indexName")="gdsutest" S ARGS("filter")="eq(""roles[]"",""ehmp-proxy"")" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") @@ -907,71 +1066,57 @@ D ASSERT("ehmp-test",$G(OBJECT("items",3,"roles",2)),"The roles array (2) was no D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles array (1) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,I,J,RSP + K ARGS,OBJECT,RSP ; Get with eq filter a value in an array (two matches) S ARGS("indexName")="gdsutest" S ARGS("filter")="eq(""roles[]"",""ehmp-test"")" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:5",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",1,"roles",2)),"The roles array (2) was not returned correctly") D ASSERT("urn:va:ut:99",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",2,"roles",1)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,I,J,RSP + K ARGS,OBJECT,RSP ; Get with complex filter (only one match) ; This is an implicit and S ARGS("indexName")="gdsutest" S ARGS("filter")="eq(""roles[]"",""ehmp-test""),eq(""uid"",""urn:va:ut:99"")" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:99",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",1,"roles",1)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,I,J,RSP + K ARGS,OBJECT,RSP ; Get with complex filter (multiple matches) ; This is an implicit and S ARGS("indexName")="gdsutest" S ARGS("filter")="or(eq(""roles[]"",""ehmp-proxy""),eq(""uid"",""urn:va:ut:99""))" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (2) was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") @@ -983,60 +1128,80 @@ D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles array (2) was n D ASSERT("urn:va:ut:99",$G(OBJECT("items",5,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-test",$G(OBJECT("items",5,"roles",1)),"The roles array (2) was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) - Q + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + QUIT ; -INDEXRANGEFILTER ;; @TEST Get index with range and filter +INDEXFILTERLOCK ;; @TEST Get index with filter and a lock on the object N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,I,J N START,LIMIT,SIZE,PREAMBLE,RSP ; Setup paging info for PAGE^VPRJRUT S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2) - K ^TMP($J) + K ^||TMP($J) + ; + ; Get Index with eq filter for an exact match + ; lock uid: urn:va:ut:7 + S ARGS("uid")="urn:va:ut:7" + S ARGS("skiplocked")="true" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:7",$G(RETURN),"The returned location header isn't as expected") + K ARGS,BODY,RETURN + ; + S ARGS("indexName")="gdsutest" + S ARGS("filter")="eq(""uid"",""urn:va:ut:7"")" + S ARGS("skiplocked")="true" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(OBJECT("items")),"items were returned that shouldn't be") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + ; Remove the lock + K ^VPRJUTL("urn:va:ut:7") + QUIT + ; +INDEXRANGEFILTER ;; @TEST Get index with range and filter + N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,I,J ; ; Get the data we've stored so far by range S ARGS("indexName")="gdsutest" S ARGS("range")="ehmp-test" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:5",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("urn:va:ut:99",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,I,J,RSP + K ARGS,OBJECT,RSP ; ; Get the data we've stored so far by range - no results S ARGS("indexName")="gdsutest" S ARGS("range")="z" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - ;D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT,0) + ; D ASSERT(0,$D(@RSP@("data")),"Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) ; Cleanup Vars - K DATA,ARGS,OBJECT,ERR,I,J,RSP + K ARGS,OBJECT,RSP ; ; Get with complex filter (multiple matches) ; This is an implicit and @@ -1044,16 +1209,11 @@ S ARGS("indexName")="gdsutest" S ARGS("filter")="or(eq(""roles[]"",""ehmp-proxy""),eq(""uid"",""urn:va:ut:99""))" S ARGS("range")="ehmp-proxy" D INDEX^VPRJGDS(.RSP,.ARGS) - D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) - ; Emulate RESPOND^VPRJRSP to get a real JSON response - S DATA(0)=PREAMBLE - F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D - . I I>START S DATA(I)="," ; separate items with a comma - . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) - S DATA(I)="]}" - D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("urn:va:ut:1",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (2) was not returned correctly") D ASSERT("urn:va:ut:2",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") @@ -1064,23 +1224,77 @@ D ASSERT("urn:va:ut:7",$G(OBJECT("items",4,"uid")),"The uid field was not return D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles array (2) was not returned correctly") D ASSERT(0,$D(OBJECT("items",5)),"More results returned than expected") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - K ^TMP($J) - Q + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + QUIT ; -PATCH1 ;; @TEST PATCH existing document - N RETURN,BODY,ARG,HTTPERR - S BODY(1)="{""lastLogin"": {""date"":""20160615120000000""}}" - S ARG("uid")="urn:va:ut:23" - S HTTPREQ("method")="PATCH" - S RETURN=$$SET^VPRJGDS(.ARG,.BODY) - D ASSERT(10,$D(^VPRJUT("urn:va:ut:23")),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") - D ASSERT("urn:va:ut:23",$G(^VPRJUT("urn:va:ut:23","uid")),"The uid field was not stored correctly") - D ASSERT("20160615120000000",$G(^VPRJUT("urn:va:ut:23","lastLogin","date")),"The lastLogin.date attribute was not stored correctly") - D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:23","The UID wasn't returned") - ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) +INDEXSTARTID ;; @TEST Get objects beginning with a selected id + N RETURN,ARGS,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR + S ARGS("startid")="urn:va:ut:2" + S ARGS("indexName")="gdsutest" + D INDEX^VPRJGDS(.DATA,.ARGS) + D PARSE(.DATA,.OBJECT) + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:2",$G(OBJECT("items",1,"uid")),"Returned list should have started with urn:va:ut:2") + D ASSERT("urn:va:ut:7",$G(OBJECT("items",3,"uid")),"urn:va:ut:7 should have been third item in list") + K ^||TMP("HTTPERR",$J),@DATA + QUIT + ; +INDEXRANGEFILTERLOCK ;; @TEST Get index with range and filter and locked object + N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,I,J + N START,LIMIT,SIZE,PREAMBLE,RSP + ; Setup paging info for PAGE^VPRJRUT + S HTTPREQ("paging")=$G(HTTPARGS("start"),0)_":"_$G(HTTPARGS("limit"),999999) + S START=$P(HTTPREQ("paging"),":"),LIMIT=$P(HTTPREQ("paging"),":",2) + K ^||TMP($J) + ; + ; Get the data we've stored so far by range + ; lock uid: urn:va:ut:5 + S ARGS("uid")="urn:va:ut:5" + S ARGS("skiplocked")="true" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:5",$G(RETURN),"The returned location header isn't as expected") + K ARGS,BODY,RETURN + ; + S ARGS("indexName")="gdsutest" + S ARGS("range")="ehmp-test" + S ARGS("skiplocked")="true" + D INDEX^VPRJGDS(.RSP,.ARGS) + D PAGE^VPRJRUT(.RSP,START,LIMIT,.SIZE,.PREAMBLE) + ; Emulate RESPOND^VPRJRSP to get a real JSON response + S DATA(0)=PREAMBLE + F I=START:1:(START+LIMIT-1) Q:'$D(@RSP@($J,I)) D + . I I>START S DATA(I)="," ; separate items with a comma + . S J="" F S J=$O(@RSP@($J,I,J)) Q:'J S DATA(I)=$G(DATA(I))_@RSP@($J,I,J) + S DATA(I)="]}" + D:$D(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:99",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT(0,$D(OBJECT("items",2)),"Too many items were returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + ; Remove the lock + K ^VPRJUTL("urn:va:ut:5") + QUIT + ; +PATCH1 ;; @TEST PATCH existing document + N RETURN,BODY,ARG,HTTPERR + S BODY(1)="{""lastLogin"": {""date"":""20160615120000000""}}" + S ARG("uid")="urn:va:ut:23" + S HTTPREQ("method")="PATCH" + S RETURN=$$SET^VPRJGDS(.ARG,.BODY) + D ASSERT(10,$D(^VPRJUT("urn:va:ut:23")),"Data NOT stored when it should be") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("urn:va:ut:23",$G(^VPRJUT("urn:va:ut:23","uid")),"The uid field was not stored correctly") + D ASSERT("20160615120000000",$G(^VPRJUT("urn:va:ut:23","lastLogin","date")),"The lastLogin.date attribute was not stored correctly") + D ASSERT($G(RETURN),"/ut/"_"urn:va:ut:23","The UID wasn't returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) K HTTPREQ("method") K BODY,RETURN,ARG ; Reset data back to what it was @@ -1089,7 +1303,7 @@ S ARG("uid")="urn:va:ut:23" S HTTPREQ("method")="PATCH" S RETURN=$$SET^VPRJGDS(.ARG,.BODY) ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K HTTPREQ("method") Q ; @@ -1100,12 +1314,12 @@ S HTTPREQ("method")="PATCH" S RETURN=$$SET^VPRJGDS(.ARG,.BODY) S UID="urn:va:ut:"_$G(^VPRJUT(0)) D ASSERT(10,$D(^VPRJUT(UID)),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT(UID,$G(^VPRJUT(UID,"uid")),"The uid field was not stored correctly") D ASSERT("20160615120000000",$G(^VPRJUT(UID,"lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT($G(RETURN),"/ut/"_UID,"The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K HTTPREQ("method") Q ; @@ -1115,18 +1329,844 @@ S BODY(1)="{""lastLogin"": {""date"":""20160615120000000""},""uid"":99999}" S HTTPREQ("method")="PATCH" S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUT(99999)),"Data NOT stored when it should be") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT(99999,$G(^VPRJUT(99999,"uid")),"The uid field was not stored correctly") D ASSERT("20160615120000000",$G(^VPRJUT(99999,"lastLogin","date")),"The lastLogin.date attribute was not stored correctly") D ASSERT($G(RETURN),"/ut/"_99999,"The UID wasn't returned") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K HTTPREQ("method") Q ; +CTEMPLATENOSTORE ;; @TEST Create TEMPLATE - Error code is set if no store in HTTPREQ + N RETURN,BODY,ARG,HTTPERR + K HTTPREQ + ; Create sample JSON + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","include, applyOnSave","roles") + ; Send it to the URL + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + S HTTPREQ("store")="ut" + Q + ; +CTEMPLATENOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG + N RETURN,BODY,ARG,HTTPERR,GLOBALSAVE + ; Create sample JSON + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","include, applyOnSave","roles") + ; Kill off the global area for the test + S GLOBALSAVE=^VPRCONFIG("store","ut","global") + K ^VPRCONFIG("store","ut","global") + ; Send it to the URL + S HTTPREQ("store")="ut" + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Restore the global area for the rest of the tests + S ^VPRCONFIG("store","ut","global")=GLOBALSAVE + Q + ; +CTEMPLATENOJSON ;; @TEST Error code is set if no JSON in body + N RETURN,BODY,ARG,HTTPERR,GLOBALSAVE + ; Send it to the URL + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(255,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 255 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + Q + ; +CTEMPLATEJSONERR ;; @TEST Error code is set if JSON is mangled in PUT/POST + N RETURN,BODY,ARG,HTTPERR + ; Create bad JSON + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","include, applyOnSave","roles") + S BODY(1)=BODY(1)_":" + ; Send it to the URL + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + Q + ; +CTEMPLATEMFIELDS ;; @TEST POST without required fields + N RETURN,BODY,ARG,HTTPERR + ; Try with an empty string for the name + S BODY(1)=$$SAMPLETEMPLATE("","include, applyOnSave","roles") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K BODY,RETURN,ARG + ; + ; Try with an empty string for the directives + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","","roles") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K BODY,RETURN,ARG + ; + ; Try with an empty string for the fields + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","include, applyOnSave","") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K BODY,RETURN,ARG + ; + ; Try with an empty string for all + S BODY(1)=$$SAMPLETEMPLATE("","","") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K BODY,RETURN,ARG + ; + ; Try with a non existent name + ; "null" is a magic string to the SAMPLETEMPLATE generator to prevent the field from even being passed + S BODY(1)=$$SAMPLETEMPLATE("null","include, applyOnSave","roles") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; + ; Try with a non existent directives + ; "null" is a magic string to the SAMPLETEMPLATE generator to prevent the field from even being passed + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","null","roles") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; + ; Try with a non existent fields + ; "null" is a magic string to the SAMPLETEMPLATE generator to prevent the field from even being passed + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","include, applyOnSave","null") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(0,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + D ASSERT(0,$D(^VPRJUTJ("TEMPLATE")),"Templates applied to existing data") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT(273,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 273 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + Q + ; +CTEMPLATE1 ;; @TEST Create 1 template (happy path) + N RETURN,BODY,ARG,HTTPERR + S BODY(1)=$$SAMPLETEMPLATE("gdsutest","include, applyOnSave","roles[]") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(10,$D(^VPRMETA("template","gdsutest")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(10,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:1","gdsutest")),"The gdsutest template is not applied as expected") + D ASSERT(10,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:5","gdsutest")),"The gdsutest template is not applied as expected") + D ASSERT(10,$D(^VPRCONFIG("store","ut","template","gdsutest")),"Template Not stored in VPRJCONFIG") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + Q + ; +CTEMPLATE2 ;; @TEST Creating 2 (additional) templates + N RETURN,BODY,ARG,HTTPERR + S BODY(1)=$$SAMPLETEMPLATE("gdsutest2","include, applyOnSave","createDate.date") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(10,$D(^VPRMETA("template","gdsutest2")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(10,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:1","gdsutest2")),"The gdsutest2 template is not applied as expected") + D ASSERT(10,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:2","gdsutest2")),"The gdsutest2 template is not applied as expected") + D ASSERT(10,$D(^VPRCONFIG("store","ut","template","gdsutest2")),"Template Not stored in VPRJCONFIG") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K RETURN,BODY,ARG + ; Update the record + S BODY(1)=$$SAMPLETEMPLATE("gdsutest3","include, applyOnSave","roles[], createDate.date") + S RETURN=$$CTEMPLATE^VPRJGDS(.ARG,.BODY) + D ASSERT(10,$D(^VPRMETA("template","gdsutest3")),"Template Not stored in VPRMETA") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(10,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:1","gdsutest3")),"The gdsutest3 template is not applied as expected") + D ASSERT(10,$D(^VPRJUTJ("TEMPLATE","urn:va:ut:2","gdsutest3")),"The gdsutest3 template is not applied as expected") + D ASSERT(10,$D(^VPRCONFIG("store","ut","template","gdsutest3")),"Template Not stored in VPRJCONFIG") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + Q +GTEMPLATEINDEX ;; @TEST Retrieve data using previously built templates using an index + N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,I,J + ; + ; Get Index with eq filter for an exact match + S ARGS("indexName")="gdsutest" + S ARGS("template")="gdsutest" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + ; + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + ; Cleanup Vars + K ARGS,OBJECT,RSP + ; Get Index with eq filter a value in an array + S ARGS("indexName")="gdsutest" + S ARGS("template")="gdsutest2" + S ARGS("filter")="eq(""uid"",""urn:va:ut:2"")" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("20000101120000000",$G(OBJECT("items",1,"createDate","date")),"The createDate.date field was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"roles",1)),"The roles field was returned and it shouldn't") + ; + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + ; Cleanup Vars + K ARGS,OBJECT,RSP + ; Get the data we've stored so far by range + S ARGS("indexName")="gdsutest" + S ARGS("range")="ehmp-test" + S ARGS("template")="gdsutest3" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("20000101120000000",$G(OBJECT("items",1,"createDate","date")),"The createDate.date field was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",2,"createDate","date")),"The createDate.date field was not returned correctly") + D ASSERT("ehmp-test",$G(OBJECT("items",2,"roles",1)),"The roles field was not returned correctly") + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + Q + ; +GTEMPLATEINDEXLOCK ;; @TEST Retrieve data using previously built templates using an index and locked record + N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR,RSP + K ^||TMP($J) + ; + ; Get Index with eq filter for an exact match + ; 5 items before + ; 4 items after + ; lock uid: urn:va:ut:1 + S ARGS("uid")="urn:va:ut:1" + S ARGS("skiplocked")="true" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:1",$G(RETURN),"The returned location header isn't as expected") + K ARGS,BODY,RETURN + ; + S ARGS("indexName")="gdsutest" + S ARGS("template")="gdsutest" + S ARGS("skiplocked")="true" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + D ASSERT(0,$D(OBJECT("items",5)),"Too many items returned") + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + ; Cleanup Vars + K DATA,ARGS,OBJECT,ERR,RETURN,RSP + ; + ; + ; + S ARGS("indexName")="gdsutest" + S ARGS("template")="gdsutest" + D INDEX^VPRJGDS(.RSP,.ARGS) + ; + ; Parse the paged response + D PARSE(.RSP,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(10,$D(OBJECT("items")),"Data does not exist and it should") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + D ASSERT(10,$D(OBJECT("items",5)),"Not enough items returned") + D ASSERT(0,$D(OBJECT("items",6)),"Too many items returned") + ; + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) + ; Remove the lock + K ^VPRJUTL("urn:va:ut:1") + QUIT + ; +GTEMPLATE ;; @TEST Get Single object with a template + N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR + ; Get the data we've stored so far + S ARGS("uid")="urn:va:ut:7" + ; gdsutest3 template only has roles and createDate.date + S ARGS("template")="gdsutest3" + D GET^VPRJGDS(.DATA,.ARGS) + D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(10,$D(^VPRJUT("urn:va:ut:7")),"Data does not exist and it should") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("roles",1)),"The role field was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("createDate","date")),"The createDate.date attribute was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K DATA,ARGS,OBJECT,ERR + ; + ; Get another object + S ARGS("uid")="urn:va:ut:5" + ; gdsutest2 template only has createDate.date + S ARGS("template")="gdsutest2" + D GET^VPRJGDS(.DATA,.ARGS) + D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(10,$D(^VPRJUT("urn:va:ut:5")),"Data does not exist and it should") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("uid")),"The uid field was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("roles",2)),"The roles array (2) was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +GTEMPLATENOID ;; @TEST All Data is returned if no uid passed with a template + N DATA,ARGS,OBJECT,HTTPERR + ; Try with a non existent uid attribute + ; gdsutest template only has roles[] + S ARGS("template")="gdsutest" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles field was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K @DATA,OBJECT,ARGS,ERR + ; Try with a null uid + S ARGS("uid")="" + ; gdsutest2 template only has createDate.date + S ARGS("template")="gdsutest2" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(11,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",4,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"roles",1)),"The roles field was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +GTEMPLATEFILTER ;; @TEST Get object with filter and template + N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR + ; Get with eq filter an exact match + S ARGS("filter")="eq(""uid"",""urn:va:ut:7"")" + ; gdsutest template only has roles[] + S ARGS("template")="gdsutest" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K @DATA,ARGS,OBJECT,ERR + ; Get with eq filter a value in an array + S ARGS("filter")="eq(""roles[]"",""ehmp-proxy"")" + ; gdsutest2 template only has createDate.date + S ARGS("template")="gdsutest2" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",1,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",2,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",2,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",2,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",3,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",3,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",3,"roles",2)),"The roles array (2) was not returned correctly") + D ASSERT("",$G(OBJECT("items",3,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",3,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",4,"createDate","date")),"The createDate.date attribute was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K @DATA,ARGS,OBJECT,ERR + ; Get with eq filter a value in an array (two matches) + S ARGS("filter")="eq(""roles[]"",""ehmp-test"")" + ; gdsutest template only has roles[] + S ARGS("template")="gdsutest" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("ehmp-test",$G(OBJECT("items",1,"roles",2)),"The roles array (2) was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + D ASSERT("",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-test",$G(OBJECT("items",2,"roles",1)),"The roles array (2) was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles field was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K @DATA,ARGS,OBJECT,ERR + ; Get with complex filter (only one match) + ; This is an implicit and + S ARGS("filter")="eq(""roles[]"",""ehmp-test""),eq(""uid"",""urn:va:ut:99"")" + ; gdsutest2 template only has createDate.date + S ARGS("template")="gdsutest2" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"roles",1)),"The roles array (2) was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",1,"createDate","date")),"The createDate.date attribute was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K @DATA,ARGS,OBJECT,ERR + ; Get with complex filter (multiple matches) + ; This is an implicit and + S ARGS("filter")="or(eq(""roles[]"",""ehmp-proxy""),eq(""uid"",""urn:va:ut:99""))" + ; gdsutest3 template only has roles and createDate.date + S ARGS("template")="gdsutest3" + D GET^VPRJGDS(.DATA,.ARGS) + ; + ; Parse the paged response + D PARSE(.DATA,.OBJECT) + ; + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT("",$G(OBJECT("items",1,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",1,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",1,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",1,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",2,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",2,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",2,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",2,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",3,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",3,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",3,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",3,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-proxy",$G(OBJECT("items",4,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",4,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",4,"createDate","date")),"The createDate.date attribute was not returned correctly") + D ASSERT("",$G(OBJECT("items",5,"uid")),"The uid field was not returned correctly") + D ASSERT("ehmp-test",$G(OBJECT("items",5,"roles",1)),"The roles array (1) was not returned correctly") + D ASSERT("",$G(OBJECT("items",5,"lastLogin","date")),"The lastLogin.date attribute was not returned correctly") + D ASSERT("20000101120000000",$G(OBJECT("items",5,"createDate","date")),"The createDate.date attribute was not returned correctly") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; + ; +SETLOCKNOSTORE ;; @TEST Error code is set if no store in HTTPREQ + N DATA,OBJECT,ERR,ARGS,HTTPERR + ; Send it to the URL + K HTTPREQ("store") + D SETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +SETLOCKNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG + N DATA,OBJECT,ERR,ARGS,HTTPERR,GLOBALSAVE + ; Kill off the global area for the test + S GLOBALSAVE=^VPRCONFIG("store","ut","global") + K ^VPRCONFIG("store","ut","global") + ; Send it to the URL + S HTTPREQ("store")="ut" + D SETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Restore the global area for the rest of the tests + S ^VPRCONFIG("store","ut","global")=GLOBALSAVE + QUIT + ; +SETLOCKIDERR ;; @TEST Error code is set if no uid + N DATA,ERR,ARGS,HTTPERR + ; Try with a non existent uid + D SETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(DATA),"No DATA should be returned") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup vars + K DATA,ERR,ARGS + ; Try with a blank uid + S ARGS("uid")="" + D SETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(DATA),"No DATA should be returned") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +SETLOCK ;; @TEST Set a Lock + N BODY,ERR,ARGS,RETURN,HTTPERR,TIMEOUT + ; Set the timeout value to something smaller so the tests don't take forever + S TIMEOUT=$G(^VPRCONFIG("store","ut","lockTimeout")) + S ^VPRCONFIG("store","ut","lockTimeout")=1 + ; Try with a uid that isn't stored yet + S ARGS("uid")="urn:va:ut:1338" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:1338",$G(RETURN),"The returned location header isn't as expected") + D ASSERT(1,$D(^VPRJUTL("urn:va:ut:1338")),"A lock should have been created") + ; Note: This only checks the YYYYMMDD of the stored date + D ASSERT($E($$CURRTIME^VPRJRUT,1,8),$E($G(^VPRJUTL("urn:va:ut:1338")),1,8),"A lock time should have been created") + D ASSERT(1,$G(^VPRJUTL("urn:va:ut:1338"))?14N,"A lock time with 14 digits should have been created") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup vars + K RETURN,ERR,ARGS + ; + ; Try with a uid that is stored + S ARGS("uid")="urn:va:ut:23" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:23",$G(RETURN),"The returned location header isn't as expected") + D ASSERT(1,$D(^VPRJUTL("urn:va:ut:23")),"A lock should have been created") + ; Note: This only checks the YYYYMMDD of the stored date + D ASSERT($E($$CURRTIME^VPRJRUT,1,8),$E($G(^VPRJUTL("urn:va:ut:23")),1,8),"A lock time should have been created") + D ASSERT(1,$G(^VPRJUTL("urn:va:ut:23"))?14N,"A lock time with 14 digits should have been created") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup vars + K RETURN,ERR,ARGS + ; + ; Try to set one that is still locked + S ARGS("uid")="urn:va:ut:23" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(1,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should have occured") + D ASSERT("",$G(RETURN),"The returned location header isn't as expected") + D ASSERT(500,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 500 error should have occured") + D ASSERT(272,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 272 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup vars + K RETURN,ERR,ARGS + ; + ; Try to set one that is after the timeout + W "waiting 3 sec for lockTimeout to pass" + H 3 + S ARGS("uid")="urn:va:ut:23" + S RETURN=$$SETLOCK^VPRJGDS(.ARGS,.BODY) + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT("/ut/lock/urn:va:ut:23",$G(RETURN),"The returned location header isn't as expected") + D ASSERT(1,$D(^VPRJUTL("urn:va:ut:23")),"A lock should have been created") + ; Note: This only checks the YYYYMMDD of the stored date + D ASSERT($E($$CURRTIME^VPRJRUT,1,8),$E($G(^VPRJUTL("urn:va:ut:23")),1,8),"A lock time should have been created") + D ASSERT(1,$G(^VPRJUTL("urn:va:ut:23"))?14N,"A lock time with 14 digits should have been created") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Return the store timeout back to what it was + S ^VPRCONFIG("store","ut","lockTimeout")=TIMEOUT + QUIT + ; +GETLOCKNOSTORE ;; @TEST Error code is set if no store in HTTPREQ + N DATA,ERR,ARGS,HTTPERR + ; Send it to the URL + K HTTPREQ("store") + D GETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +GETLOCKNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG + N DATA,ERR,ARGS,HTTPERR,GLOBALSAVE + ; Kill off the global area for the test + S GLOBALSAVE=^VPRCONFIG("store","ut","global") + K ^VPRCONFIG("store","ut","global") + ; Send it to the URL + S HTTPREQ("store")="ut" + D GETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Restore the global area for the rest of the tests + S ^VPRCONFIG("store","ut","global")=GLOBALSAVE + QUIT + ; +GETLOCKNOID ;; @TEST Data is returned if no uid passed + N DATA,ARGS,OBJECT,HTTPERR,ERR + ; Add some test data + K ^VPRJUTL + S ^VPRJUTL("urn:va:ut:1")=$$CURRTIME^VPRJRUT + S ^VPRJUTL("urn:va:ut:12")=$$CURRTIME^VPRJRUT + S ^VPRJUTL("urn:va:ut:4")=$$CURRTIME^VPRJRUT + S ^VPRJUTL("urn:va:ut:7")=$$CURRTIME^VPRJRUT + ; Try with a non existent uid attribute + D GETLOCK^VPRJGDS(.DATA,.ARGS) + D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") + D ASSERT(1,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(1,$D(OBJECT("items",4,"urn:va:ut:7")),"The uid was not returned correctly") + D ASSERT(0,$D(OBJECT("items",5)),"Too many entries were returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup Vars + K DATA,OBJECT,ARGS,ERR + ; Try with a null uid + S ARGS("uid")="" + D GETLOCK^VPRJGDS(.DATA,.ARGS) + D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") + D ASSERT(1,$D(DATA),"DATA should be returned") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(1,$D(OBJECT("items",4,"urn:va:ut:7")),"The uid was not returned correctly") + D ASSERT(0,$D(OBJECT("items",5)),"Too many entries were returned") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +GETLOCKUIDUNK ;; @TEST Error code if uid doesn't exist + N DATA,ARGS,HTTPERR + ; Try with a non existent uid attribute + S ARGS("uid")="urn:va:ut:1337" + D GETLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(DATA),"No DATA should be returned") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(229,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 229 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +DELLOCKNOSTORE ;; @TEST Error code is set if no store in HTTPREQ + N DATA,ERR,ARGS,HTTPERR + ; Send it to the URL + K HTTPREQ("store") + D DELLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +DELLOCKNOGLOBAL ;; @TEST Error code is set if no global is in VPRCONFIG + N DATA,ERR,ARGS,HTTPERR,GLOBALSAVE + ; Kill off the global area for the test + S GLOBALSAVE=^VPRCONFIG("store","ut","global") + K ^VPRCONFIG("store","ut","global") + ; Send it to the URL + S HTTPREQ("store")="ut" + D DELLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(^VPRCONFIG("store","ut","global")),"VPRCONFIG global storage area exists and it shouldn't") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(253,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 253 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Restore the global area for the rest of the tests + S ^VPRCONFIG("store","ut","global")=GLOBALSAVE + QUIT + ; +DELLOCKIDERR ;; @TEST Error code is set if no uid for lock table + N DATA,ERR,ARGS,HTTPERR + ; Try with a non existent uid + D DELLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(DATA),"No DATA should be returned") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; Cleanup vars + K DATA,OBJECT,ERR,ARGS + ; Try with a blank uid + S ARGS("uid")="" + D DELLOCK^VPRJGDS(.DATA,.ARGS) + D ASSERT(0,$D(DATA),"No DATA should be returned") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; +DELLOCK ;; @TEST Delete Lock + N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR + ; delete non-existent lock + S ARGS("uid")="urn:va:ut:23" + D DELLOCK^VPRJGDS(.DATA,.ARGS) + D:$G(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^VPRJUTL("urn:va:ut:23")),"Data exists and it should not") + D ASSERT("true",$G(OBJECT("ok")),"No DATA returned from a DELETE call (should not happen)") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + ; + ; Create a lock so we can delete it + S ^VPRJUTL("urn:va:ut:1337")=$$CURRTIME^VPRJRUT + ; delete lock + S ARGS("uid")="urn:va:ut:1337" + D DELLOCK^VPRJGDS(.DATA,.ARGS) + D:$G(DATA)'="" DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") + D ASSERT(0,$D(^VPRJUTL("urn:va:ut:1337")),"Data exists and it should not") + D ASSERT("true",$G(OBJECT("ok")),"No DATA returned from a DELETE call (should not happen)") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT + ; + ; +DELFILTER ;; @TEST Delete Data by filter + N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR + ; create some sample data + S BODY(1)=$$SAMPLEDATA("""ehmp-proxy""","urn:va:ut:265") + S RETURN=$$SET^VPRJGDS(.ARG,.BODY) + D ASSERT("/ut/urn:va:ut:265",RETURN,"Sample data did not get set correctly") + K BODY S BODY(1)=$$SAMPLEDATA("""rdk-proxy""","urn:va:ut:366") + S RETURN=$$SET^VPRJGDS(.ARG,.BODY) + D ASSERT("/ut/urn:va:ut:366",RETURN,"Sample data did not get set correctly") + K BODY S BODY(1)=$$SAMPLEDATA("""ehmp-doctor""","urn:va:ut:367") + S RETURN=$$SET^VPRJGDS(.ARG,.BODY) + D ASSERT("/ut/urn:va:ut:367",RETURN,"Sample data did not get set correctly") + K BODY S BODY(1)=$$SAMPLEDATA("""ehmp-nurse""","urn:va:ut:268") + S RETURN=$$SET^VPRJGDS(.ARG,.BODY) + D ASSERT("/ut/urn:va:ut:268",RETURN,"Sample data did not get set correctly") + ; delete all uids that contain a 3 + S ARGS("filter")="ilike(""uid"",""%3%"")" + D DEL^VPRJGDS(.DATA,.ARGS) + D DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(0,$D(ERR),"Error returned from Delete call") + D ASSERT(0,$D(^VPRJUT("urn:va:ut:367"))!$D(^VPRJUT("urn:va:ut:366")),"Data exists and it should not") + D ASSERT(0,$D(^VPRJUTJ("JSON","urn:va:ut:367"))!$D(^VPRJUTJ("JSON","urn:va:ut:366")),"Data exists and it should not") + D ASSERT(1,$D(^VPRJUT("urn:va:ut:268"))&$D(^VPRJUT("urn:va:ut:265")),"Data doesn't exist that should") + D ASSERT(1,$D(^VPRJUTJ("JSON","urn:va:ut:268"))&$D(^VPRJUTJ("JSON","urn:va:ut:265")),"Data doesn't exist that should") + D ASSERT("true",$G(OBJECT("ok")),"Delete call returned unexpected data") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + Q + ; +DELALL ;; @TEST Delete all data + N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR,STORE + ; delete it all + S ARGS("confirm")="true" + S STORE=^VPRCONFIG("store","ut","global") + D DEL^VPRJGDS(.DATA,.ARGS) + D DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT(0,$D(ERR),"Error returned when parsing Delete return") + D ASSERT("",$O(^VPRJUT(0)),"Data exists and it should not") + D ASSERT("",$O(^VPRJUTJ("JSON",0)),"Data exists and it should not") + D ASSERT(1,$D(^VPRCONFIG("store","ut","global")),"Data store global node definition in ^VPRJCONFIG was lost!") + D ASSERT(10,$D(^VPRCONFIG("store","ut","index")),"Data store index definitions in ^VPRJCONFIG were lost!") + D ASSERT(10,$D(^VPRCONFIG("store","ut","template")),"Data store index definitions in ^VPRJCONFIG were lost!") + D ASSERT("true",$G(OBJECT("ok")),"Delete call returned unexpected data") + D ASSERT(0,$D(@STORE@(0)),"GDS data store uid counter was not reset, and it should have been") + ; Cleanup HTTPERR + K ^||TMP("HTTPERR",$J) + QUIT ; CLR ;; @TEST Clear ALL Generic Data Store data and route map N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR,URLMAPNUM + ; Set a lock so one exists + S ^VPRJUTL("urn:va:ut:23")=$$CURRTIME^VPRJRUT D CLR^VPRJGDS(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT("{""ok"": true}",$G(DATA),"Invalid DATA returned from a DELETE call") @@ -1134,6 +2174,7 @@ D ASSERT("{""ok"": true}",$G(DATA),"Invalid DATA returned from a DELETE call") D ASSERT(0,$D(^VPRJUT),"Data exists and it should not") D ASSERT(0,$D(^VPRJUTJ),"JSON Data exists and it should not") D ASSERT(0,$D(^VPRJUTX),"Index Data exists and it should not") + D ASSERT(0,$D(^VPRJUTL),"Lock Table Data exists and it should not") ; Ensure route map index doesn't contain data D ASSERT(0,$D(^VPRCONFIG("urlmap","index",HTTPREQ("store"))),"Route map still has entries for this data store and it should not") D ASSERT(0,$D(^VPRCONFIG("urlmap","index",HTTPREQ("store"))),"Route map still has entries for this data store and it should not") @@ -1143,19 +2184,19 @@ D ASSERT(0,$D(^VPRCONFIG("urlmap","index",HTTPREQ("store"))),"Route map still ha . I ^VPRCONFIG("urlmap",URLMAPNUM,"store")=HTTPREQ("store") D . . D ASSERT(0,$D(^VPRCONFIG("urlmap",URLMAPNUM,"store")),"Route map still has entries for this data store and it should not") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) - Q + K ^||TMP("HTTPERR",$J) + QUIT ; ; RDKSESSION ;; @TEST Realistic RDK session store test N HTTPREQ,HTTPERR ; Create Store D ADDSTORE^VPRJCONFIG("utses") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Add sample session N RETURN,BODY,ARG,HTTPREQ,DATA,ERR S HTTPREQ("store")="utses" - S BODY(1)="{""uid"":""ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-"",""expires"":""2016-06-09T19:02:09.395Z"",""session"":{""cookie"":{""expires"":""2016-06-09T19:02:09.395Z"",""httpOnly"":true,""originalMaxAge"":899998,""path"":""/""},""csrf"":{""secret"":""v06210J1hu2MYpqUwg0IeJwZ""},""jwt"":{""secret"":""zTAhkVWhJ4DHC13_0lNSAyW5""},""user"":{""accessCode"":""PW "",""consumerType"":""user"",""corsTabs"":""true"",""dgRecordAccess"":""false"",""dgSecurityOfficer"":""false"",""dgSensitiveAccess"":""false"",""disabled"":false,""division"":""500"",""divisionSelect"":false,""duz"":{""9E7A"":""10000000270""},""eHMPUIContext"":[{""lastAccessed"":""20160609103852321"",""patientId"":{""type"":""pid"",""value"":""9E7A;100022""},""patientIdentifier"":""pid:9E7A;100022"",""workspaceContext"":{""contextId"":""patient"",""workspaceId"":""overview""}},{""lastAccessed"":""20160609115349599"",""patientId"":{""type"":""pid"",""value"":""9E7A;3""},""patientIdentifier"":""pid:9E7A;3"",""workspaceContext"":{""contextId"":""patient"",""workspaceId"":""overview""}}],""expires"":""2016-06-09T19:02:09.395Z"",""facility"":""PANORAMA"",""firstname"":""PANORAMA"",""infoButtonOid"":""1.3.6.1.4.1.3768"",""lastname"":""USER"",""password"":""PW !!"",""pcmm"":[{""roles"":[""NURSE (RN)"",""NURSE PRACTITIONER"",""OIF OEF CLINICAL CASE MANAGER"",""PHYSICIAN-ATTENDING"",""PHYSICIAN-PRIMARY CARE"",""RN CARE COORDINATOR"",""SOCIAL WORKER""],""service"":[""HOME TELEHEALTH"",""HOSPITAL MEDICINE"",""IMAGING"",""INFECTIOUS DISEASE""],""team"":[""TEAM1"",""TEAM2"",""TEAM3""]}],""permissionSets"":[""read-access"",""standard-doctor""],""permissions"":[""read-active-medication"",""read-allergy"",""read-clinical-reminder"",""read-community-health-summary"",""read-document"",""read-encounter"",""read-immunization"",""read-medication-review"",""read-order"",""read-patient-history"",""read-condition-problem"",""read-patient-record"",""access-stack-graph"",""read-task"",""read-vital"",""read-vista-health-summary"",""read-stack-graph"",""read-timeline"",""add-active-medication"",""add-allergy"",""add-condition-problem"",""add-consult-order"",""add-encounter"",""add-immunization"",""add-lab-order"",""add-med-order"",""add-non-va-medication"",""add-note"",""add-note-addendum"",""add-patient-history"",""add-radiology-order"",""add-task"",""add-vital"",""cancel-task"",""complete-consult-order"",""cosign-lab-order"",""cosign-med-order"",""cosign-note"",""cosign-radiology-order"",""delete-note"",""discontinue-active-medication"",""discontinue-consult-order"",""discontinue-lab-order"",""discontinue-med-order"",""discontinue-radiology-order"",""edit-active-medication"",""edit-allergy"",""edit-condition-problem"",""edit-consult-order"",""edit-encounter-form"",""edit-lab-order"",""edit-med-order"",""edit-non-va-medication"",""edit-note"",""edit-note-addendum"",""edit-patient-history"",""edit-radiology-order"",""edit-task"",""eie-allergy"",""eie-immunization"",""eie-patient-history"",""eie-vital"",""release-lab-order"",""release-med-order"",""release-radiology-order"",""remove-condition-problem"",""schedule-consult-order"",""sign-consult-order"",""sign-lab-order"",""sign-med-order"",""sign-note"",""sign-note-addendum"",""sign-radiology-order"",""triage-consult-order"",""abort-task"",""edit-encounter"",""eie-encounter"",""edit-immunization"",""edit-vital""],""provider"":true,""requiresReset"":false,""rptTabs"":""false"",""section"":""Medicine"",""sessionLength"":900000,""site"":""9E7A"",""ssn"":666441233,""title"":""Clinician"",""uid"":""urn:va:user:9E7A:10000000270"",""username"":""9E7A;PW "",""verifyCode"":""PW !!"",""vistaKeys"":[""GMRA-SUPERVISOR"",""GMRC101"",""GMV MANAGER"",""ORES"",""PROVIDER"",""PSB CPRS MED BUTTON""],""vistaUserClass"":[{""role"":""USER"",""uid"":""urn:va:asu-class:9E7A:561""}]}}}" + S BODY(1)="{""uid"":""ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-"",""expires"":""2016-06-09T19:02:09.395Z"",""session"":{""cookie"":{""expires"":""2016-06-09T19:02:09.395Z"",""httpOnly"":true,""originalMaxAge"":8PORT8,""path"":""/""},""csrf"":{""PW "":""v06210J1hu2MYpqUwg0IeJwZ""},""jwt"":{""PW "":""zTAhkVWhJ4DHC13_0lNSAyW5""},""user"":{""accessCode"":""USER "",""consumerType"":""user"",""corsTabs"":""true"",""dgRecordAccess"":""false"",""dgSecurityOfficer"":""false"",""dgSensitiveAccess"":""false"",""disabled"":false,""division"":""500"",""divisionSelect"":false,""duz"":{""SITE"":""10000000270""},""eHMPUIContext"":[{""lastAccessed"":""20160609103852321"",""patientId"":{""type"":""pid"",""value"":""SITE;100022""},""patientIdentifier"":""pid:SITE;100022"",""workspaceContext"":{""contextId"":""patient"",""workspaceId"":""overview""}},{""lastAccessed"":""20160609115349599"",""patientId"":{""type"":""pid"",""value"":""SITE;3""},""patientIdentifier"":""pid:SITE;3"",""workspaceContext"":{""contextId"":""patient"",""workspaceId"":""overview""}}],""expires"":""2016-06-09T19:02:09.395Z"",""facility"":""PANORAMA"",""firstname"":""PANORAMA"",""infoButtonOid"":""1.3.6.1.4.1.3768"",""lastname"":""USER"",""password"":""PW "",""pcmm"":[{""roles"":[""NURSE (RN)"",""NURSE PRACTITIONER"",""OIF OEF CLINICAL CASE MANAGER"",""PHYSICIAN-ATTENDING"",""PHYSICIAN-PRIMARY CARE"",""RN CARE COORDINATOR"",""SOCIAL WORKER""],""service"":[""HOME TELEHEALTH"",""HOSPITAL MEDICINE"",""IMAGING"",""INFECTIOUS DISEASE""],""team"":[""TEAM1"",""TEAM2"",""TEAM3""]}],""permissionSets"":[""read-access"",""standard-doctor""],""permissions"":[""read-active-medication"",""read-allergy"",""read-clinical-reminder"",""read-community-health-summary"",""read-document"",""read-encounter"",""read-immunization"",""read-medication-review"",""read-order"",""read-patient-history"",""read-condition-problem"",""read-patient-record"",""access-stack-graph"",""read-task"",""read-vital"",""read-vista-health-summary"",""read-stack-graph"",""read-timeline"",""add-active-medication"",""add-allergy"",""add-condition-problem"",""add-consult-order"",""add-encounter"",""add-immunization"",""add-lab-order"",""add-med-order"",""add-non-va-medication"",""add-note"",""add-note-addendum"",""add-patient-history"",""add-radiology-order"",""add-task"",""add-vital"",""cancel-task"",""complete-consult-order"",""cosign-lab-order"",""cosign-med-order"",""cosign-note"",""cosign-radiology-order"",""delete-note"",""discontinue-active-medication"",""discontinue-consult-order"",""discontinue-lab-order"",""discontinue-med-order"",""discontinue-radiology-order"",""edit-active-medication"",""edit-allergy"",""edit-condition-problem"",""edit-consult-order"",""edit-encounter-form"",""edit-lab-order"",""edit-med-order"",""edit-non-va-medication"",""edit-note"",""edit-note-addendum"",""edit-patient-history"",""edit-radiology-order"",""edit-task"",""eie-allergy"",""eie-immunization"",""eie-patient-history"",""eie-vital"",""release-lab-order"",""release-med-order"",""release-radiology-order"",""remove-condition-problem"",""schedule-consult-order"",""sign-consult-order"",""sign-lab-order"",""sign-med-order"",""sign-note"",""sign-note-addendum"",""sign-radiology-order"",""triage-consult-order"",""abort-task"",""edit-encounter"",""eie-encounter"",""edit-immunization"",""edit-vital""],""provider"":true,""requiresReset"":false,""rptTabs"":""false"",""section"":""Medicine"",""sessionLength"":900000,""site"":""SITE"",""ssn"":666441233,""title"":""Clinician"",""uid"":""urn:va:user:SITE:10000000270"",""username"":""PW "",""verifyCode"":""PW "",""vistaKeys"":[""GMRA-SUPERVISOR"",""GMRC101"",""GMV MANAGER"",""ORES"",""PROVIDER"",""PSB CPRS MED BUTTON""],""vistaUserClass"":[{""role"":""USER"",""uid"":""urn:va:asu-class:SITE:561""}]}}}" S RETURN=$$SET^VPRJGDS(.ARG,.BODY) D ASSERT(10,$D(^VPRJUTSES("ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-")),"Data NOT stored when it should be") ; Patch the expires date/times @@ -1172,10 +2213,10 @@ D ASSERT("2016-06-15T16:19:00.000Z",$G(^VPRJUTSES("ZOUjqD3uh48eOuMrB4meSlCzcFV9I ; retrieve the object S ARG("uid")="ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-" D GET^VPRJGDS(.DATA,.ARG) - D:$G(DATA)'="" DECODE^VPRJSON(DATA,"OBJECT","ERR") + D:$D(DATA) DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJUTSES("ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-")),"Data does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-",$G(OBJECT("uid")),"The uid field was not returned correctly") D ASSERT("2016-06-15T16:19:00.000Z",$G(OBJECT("expires")),"object.expires not stored correctly") D ASSERT("2016-06-15T16:19:00.000Z",$G(OBJECT("session","cookie","expires")),"object.session.cookie.expires not stored correctly") @@ -1187,5 +2228,7 @@ S ARGS("uid")="ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-" D ASSERT(0,$D(^VPRJUTSES("ZOUjqD3uh48eOuMrB4meSlCzcFV9IWv-")),"Session still exists and shouldn't") K ARGS,DATA ; Kill the data stores - D CLR - Q + D CLR^VPRJGDS(.DATA,.ARGS) + D DECODE^VPRJSON("DATA","OBJECT","ERR") + D ASSERT("{""ok"": true}",$G(DATA),"Invalid DATA returned from a DELETE call") + QUIT diff --git a/VPRJTGDSN.m b/VPRJTGDSN.m new file mode 100644 index 0000000..49b13a1 --- /dev/null +++ b/VPRJTGDSN.m @@ -0,0 +1,616 @@ +VPRJTGDSN ;V4W/DLW -- Unit tests for generic data store wrapper code for pjdsClient using cache.node + ; +STARTUP ; Run once before all tests + QUIT + ; +SHUTDOWN ; Run once after all tests + QUIT + ; +SETUP ; Run before each test + K ^||TMP + QUIT + ; +TEARDOWN ; Run after each test + K ^||TMP + QUIT + ; +ASSERT(EXPECT,ACTUAL,MSG) ; convenience + D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) + QUIT + ; + ; +CREATEDBMISSINGSTORE ;; @TEST create new data store with empty store name + N ERROR,RESULT,STORE,UUID + S STORE="" + ; + S RESULT=$$CREATEDB^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Store name too long or not specified",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(252,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEDBLONGSTORE ;; @TEST create new data store with a store name that is too long + N ERROR,RESULT,STORE,UUID + S STORE="testdatastore" + ; + S RESULT=$$CREATEDB^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Store name too long or not specified",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(252,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEDBBADSTORE ;; @TEST create new data store with a bad store name + N ERROR,RESULT,STORE,UUID + S STORE="test+store" + ; + S RESULT=$$CREATEDB^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Store name too long or not specified",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(252,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEDB ;; @TEST create new data store successfully + N ERROR,RESULT,STORE,UUID + S STORE="teststore" + ; + S RESULT=$$CREATEDB^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +GETINFOMISSINGSTORE ;; @TEST get store info with empty store name + N ERROR,RESULT,STORE,UUID + S STORE="" + ; + S RESULT=$$INFO^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETINFO ;; @TEST get store info successfully + N ERROR,RESULT,STORE,UUID + S STORE="teststore" + ; + S RESULT=$$INFO^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""committed_update_seq"":0,""compact_running"":false,""data_size"":0,""db_name"":""teststore"",",$G(^TMP(UUID,$J,1))) + D ASSERT("""disk_format_version"":1,""disk_size"":0,""doc_count"":0,""doc_del_count"":0,""instance_start_time"":0,",$G(^TMP(UUID,$J,2))) + D ASSERT("""purge_seq"":0,""update_seq"":0}",$G(^TMP(UUID,$J,3))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +SETDATAMISSINGSTORE ;; @TEST add data to store with empty store name + N ERROR,PATCH,NODEUUID,RESULT,STORE,UID,UUID + S STORE="" + S UID="urn:va:teststore:1" + S PATCH="false" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""authorUid"":""urn:va:user:SITE:3"",""displayName"":""Rheumatology"",""domain"":""test-data"",""ehmpState"":""active""}" + ; + S RESULT=$$SET^VPRJGDSN(STORE,UID,PATCH,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +SETDATAWITHUID ;; @TEST add data to store passing uid successfully + N ERROR,PATCH,NODEUUID,RESULT,STORE,UID,UUID + S STORE="teststore" + S UID="urn:va:teststore:1" + S PATCH="false" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""authorUid"":""urn:va:user:SITE:3"",""displayName"":""Rheumatology"",""domain"":""test-data"",""ehmpState"":""active""}" + ; + S RESULT=$$SET^VPRJGDSN(STORE,UID,PATCH,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +SETDATAWITHOUTUID ;; @TEST add data to store without passing uid successfully + N ERROR,PATCH,NODEUUID,RESULT,STORE,UID,UUID + S STORE="teststore" + S UID="" + S PATCH="false" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498330" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""authorUid"":""urn:va:user:SITE:5"",""displayName"":""Consult"",""domain"":""test-data"",""ehmpState"":""passive""}" + ; + S RESULT=$$SET^VPRJGDSN(STORE,UID,PATCH,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +GETDATAMISSINGSTORE ;; @TEST get store data with empty store name + N ERROR,RESULT,STORE,UID,UUID + S STORE="" + S UID="urn:va:teststore:1" + ; + S RESULT=$$GET^VPRJGDSN(STORE,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETDATAWITHUID ;; @TEST get store data with a uid successfully + N ERROR,RESULT,STORE,UID,UUID + S STORE="teststore" + S UID="urn:va:teststore:1" + ; + S RESULT=$$GET^VPRJGDSN(STORE,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""authorUid"":""urn:va:user:SITE:3"",""displayName"":""Rheumatology"",""domain"":""test-data"",""ehmpState"":""active""}",$G(^TMP(UUID,$J,1))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +GETDATAWITHOUTUID ;; @TEST get store data without a uid successfully + N ERROR,RESULT,STORE,UID,UUID + S STORE="teststore" + S UID="" + ; + S RESULT=$$GET^VPRJGDSN(STORE,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""authorUid"":""urn:va:user:SITE:3"",""displayName"":""Rheumatology"",""domain"":""test-data"",""ehmpState"":""active""}",$G(^TMP(UUID,$J,0,1))) + D ASSERT("{""authorUid"":""urn:va:user:SITE:5"",""displayName"":""Consult"",""domain"":""test-data"",""ehmpState"":""passive"",",$G(^TMP(UUID,$J,1,1))) + D ASSERT("""uid"":""urn:va:teststore:2""}",$G(^TMP(UUID,$J,1,2))) + D ASSERT("]}",$G(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT("{""items"":[",$G(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(200,$G(^TMP(UUID,$J,"STATUS"))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +CREATEINDEXMISSINGSTORE ;; @TEST add index to store with empty store name + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""indexName"":""testindex"",""fields"":""authorUid"",""sort"":""desc"",""type"":""attr""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEINDEXMISSINGNAME ;; @TEST add index to store with missing index name + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="teststore" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""fields"":""authorUid"",""sort"":""desc"",""type"":""attr""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("required field missing",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Unknown error",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(273,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEINDEXMISSINGFIELDS ;; @TEST add index to store with missing fields + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="teststore" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""indexName"":""testindex"",""sort"":""desc"",""type"":""attr""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("required field missing",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Unknown error",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(273,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEINDEXMISSINGSORT ;; @TEST add index to store with missing sort + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="teststore" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""indexName"":""testindex"",""fields"":""authorUid"",""type"":""attr""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("required field missing",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Unknown error",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(273,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEINDEXMISSINGTYPE ;; @TEST add index to store with missing type + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="teststore" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""indexName"":""testindex"",""fields"":""authorUid"",""sort"":""desc""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("required field missing",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Unknown error",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(273,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CREATEINDEX ;; @TEST add index to store successfully + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="teststore" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""indexName"":""testindex"",""fields"":""authorUid"",""sort"":""desc"",""type"":""attr""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +CREATEINDEXDUPLICATE ;; @TEST add index to store when one already exists + N ERROR,NODEUUID,RESULT,STORE,UUID + S STORE="teststore" + S NODEUUID="1s4a817b-93ff-4e7f-8af4-0de4a2498329" + ; + S ^TMP("BODY",NODEUUID,$J,"data",1)="{""indexName"":""testindex"",""fields"":""authorUid"",""sort"":""desc"",""type"":""attr""}" + ; + S RESULT=$$CINDEX^VPRJGDSN(STORE,NODEUUID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("index name: testindex",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Duplicate index found",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(271,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETINDEXMISSINGSTORE ;; @TEST get index data with empty store name + N ERROR,INDEX,RESULT,STORE,UUID + S STORE="" + S INDEX="testindex" + ; + S RESULT=$$INDEX^VPRJGDSN(STORE,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETINDEXMISSINGINDEX ;; @TEST get index data with empty index name + N ERROR,INDEX,RESULT,STORE,UUID + S STORE="teststore" + S INDEX="" + ; + S RESULT=$$INDEX^VPRJGDSN(STORE,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Invalid index name",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(102,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +GETINDEX ;; @TEST get index data successfully + N ERROR,INDEX,RESULT,STORE,UUID + S STORE="teststore" + S INDEX="testindex" + ; + S RESULT=$$INDEX^VPRJGDSN(STORE,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""authorUid"":""urn:va:user:SITE:3"",""displayName"":""Rheumatology"",""domain"":""test-data"",""ehmpState"":",$G(^TMP(UUID,$J,0,1))) + D ASSERT("""active"",""uid"":""urn:va:teststore:1""}",$G(^TMP(UUID,$J,0,2))) + D ASSERT("{""authorUid"":""urn:va:user:SITE:5"",""displayName"":""Consult"",""domain"":""test-data"",""ehmpState"":""passive"",",$G(^TMP(UUID,$J,1,1))) + D ASSERT("""uid"":""urn:va:teststore:2""}",$G(^TMP(UUID,$J,1,2))) + D ASSERT("]}",$G(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT("{""items"":[",$G(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(200,$G(^TMP(UUID,$J,"STATUS"))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +DELETEDATAMISSINGSTORE ;; @TEST remove data item with empty store name + N DELETEALL,ERROR,STORE,RESULT,UID,UUID + S STORE="" + S UID="urn:va:teststore:1" + S DELETEALL="false" + ; + S RESULT=$$DEL^VPRJGDSN(STORE,UID,DELETEALL) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +DELETEDATAITEM ;; @TEST remove a data item successfully + N DELETEALL,ERROR,STORE,RESULT,UID,UUID + S STORE="teststore" + S UID="urn:va:teststore:1" + S DELETEALL="false" + ; + S RESULT=$$DEL^VPRJGDSN(STORE,UID,DELETEALL) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""ok"": true}",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +DELETEALLDATAFALSE ;; @TEST remove all data items with empty uid and deleteall set to false + N DELETEALL,ERROR,STORE,RESULT,UID,UUID + S STORE="teststore" + S UID="" + S DELETEALL="false" + ; + S RESULT=$$DEL^VPRJGDSN(STORE,UID,DELETEALL) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("uid is blank",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Unrecognized parameter",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(111,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +DELETEALLDATATRUE ;; @TEST remove all data items with empty uid and deleteall set to true successfully + N DELETEALL,ERROR,STORE,RESULT,UID,UUID + S STORE="teststore" + S UID="" + S DELETEALL="true" + ; + S RESULT=$$DEL^VPRJGDSN(STORE,UID,DELETEALL) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""ok"": true}",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; +CLEARDBMISSINGSTORE ;; @TEST remove store and all its data with empty store name + N ERROR,STORE,RESULT,UUID + S STORE="" + ; + S RESULT=$$CLR^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("JDS isn't setup correctly, run VPRJCONFIG",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(253,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + ; cleanup ^TMP + K ^TMP("HTTPERR",UUID,$J) + ; + QUIT + ; +CLEARDB ;; @TEST remove store and all its data successfully + N ERROR,STORE,RESULT,UUID + S STORE="teststore" + ; + S RESULT=$$CLR^VPRJGDSN(STORE) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT("{""ok"": true}",$G(^TMP(UUID,$J))) + ; + ; cleanup ^TMP + K ^TMP(UUID,$J) + ; + QUIT + ; diff --git a/VPRJTHDR.m b/VPRJTHDR.m index b42b341..8eccd01 100644 --- a/VPRJTHDR.m +++ b/VPRJTHDR.m @@ -1,5 +1,4 @@ VPRJTHDR ;KRM/CJE -- Integration tests for Patient Data and HDR - ;;1.0;JSON DATA STORE;;May 05, 2015 ; STARTUP ; Run once before all tests N I,TAGS @@ -11,7 +10,7 @@ K ^VPRPTJ K ^VPRPT K ^VPRMETA("JPID") - K ^TMP + K ^||TMP Q SETUP ; Run before each test K HTTPREQ,HTTPERR,HTTPRSP @@ -25,12 +24,23 @@ K ^VPRPTJ K ^VPRPT K ^VPRMETA("JPID") - K ^TMP + K ^||TMP Q ASSERT(EXPECT,ACTUAL,MSG) ; convenience D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) Q ; + ; POST data for POST query tests +POSTDATA1 ;; test POST query data for EVERY + ;;{"start":3,"limit":3} + ;;zzzzz +POSTDATA2 ;; test POST query data for FINDPAR + ;;{"filter":"eq(\"products[].ingredientName\",\"METFORMIN\") eq(\"dosages[].dose\",\"250 MG\")"} + ;;zzzzz +POSTDATA3 ;; test POST query data for FINDLIKE + ;;{"filter":"like(\"products[].ingredientName\",\"ASPIRIN%25\")"} + ;;zzzzz + ; GETUID ;; @TEST getting an object by UID only N JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID ; The hang commands are necessary to ensure subsequent accesses on the lastAccessTime node don't happen within the same second @@ -275,7 +285,7 @@ D ASSERT(0,$G(HTTPERR)) K HTTPERR D DATA2ARY^VPRJTX(.JSON) D ASSERT(6,$G(JSON("data","totalItems"))) - D ASSERT(0,$D(^TMP($J,$J))) + D ASSERT(0,$D(^||TMP($J,$J))) S VPRJTPID1=$$JPID4PID^VPRJPR(VPRJTPID) ; Cache is disable ;D ASSERT(10,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID1_"/every////")))) @@ -289,6 +299,12 @@ D ASSERT(3,$G(JSON("data","currentItemCount"))) ; Cache is disabled ;D ASSERT(10,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID1_"/every////")))) ;D ASSERT(0,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID1_"/every////"),$J))) + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/every?query=true","POSTDATA1","VPRJTHDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + K HTTPERR,JSON + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(3,$G(JSON("data","currentItemCount"))) Q FINDALL ;; @TEST finding every object in collection N JSON,ERR,HTTPERR,FLAG,ITEM,PTIME,TIME,VPRJPID @@ -352,6 +368,15 @@ D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(1,$G(JSON("data","totalItems"))) D ASSERT("urn:va:med:93EF:-7:16982",$G(JSON("data","items",1,"uid"))) + ; test POST query version + K JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/find/med?query=true","POSTDATA2","VPRJTHDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + K HTTPERR + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(1,$G(JSON("data","totalItems"))) + D ASSERT("urn:va:med:93EF:-7:16982",$G(JSON("data","items",1,"uid"))) Q FINDLIKE ;; finding using like() N JSON,ERR,HTTPERR @@ -362,4 +387,13 @@ D ASSERT(0,$G(HTTPERR)) D DATA2ARY^VPRJTX(.JSON) D ASSERT(1,$G(JSON("data","totalItems"))) D ASSERT("urn:va:med:93EF:-7:18068",$G(JSON("data","items",1,"uid"))) + ; test POST query version + K JSON,ERR,HTTPERR + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/find/med?query=true","POSTDATA3","VPRJTHDR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + K HTTPERR + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(1,$G(JSON("data","totalItems"))) + D ASSERT("urn:va:med:93EF:-7:18068",$G(JSON("data","items",1,"uid"))) Q diff --git a/VPRJTJOB.m b/VPRJTJOB.m old mode 100755 new mode 100644 index 6dea71a..6c92bf7 --- a/VPRJTJOB.m +++ b/VPRJTJOB.m @@ -18,7 +18,7 @@ SHUTDOWN ; Run once after all tests K ^VPRJOB K ^VPRPTJ("JPID") - K ^TMP + K ^||TMP Q ASSERT(EXPECT,ACTUAL,MSG) ; for convenience D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) @@ -41,16 +41,20 @@ S ^VPRPTJ("JPID","2345V5432")="52833885-af7c-4899-90be-b3a6630b2370" Q ; -JOBSTAT(JOB,ROOT,JPID,TYPE,STAMP,STATUS) ; Setup Job status JSON - Q "{""jobId"": """_JOB_""",""rootJobId"": """_ROOT_""",""jpid"": """_JPID_""",""type"": """_TYPE_""",""timestamp"": """_STAMP_""",""payload"": { ""test"": ""true"" },""status"": """_STATUS_"""}" -JOBSTATG(JOB,ROOT,JPID,TYPE,STAMP,STATUS) ; Setup Job status Global - N VPRCNT +JOBSTAT(JOB,ROOT,PIDTYPE,PID,TYPE,STAMP,STATUS) ; Setup Job status JSON + Q "{""jobId"": """_JOB_""",""rootJobId"": """_ROOT_""",""jpid"":"""_$$JPID4PID^VPRJPR(PID)_""",""patientIdentifier"":{""type"": """_PIDTYPE_""",""value"": """_PID_"""},""type"": """_TYPE_""",""timestamp"": """_STAMP_""",""payload"": { ""test"": ""true"" },""status"": """_STATUS_"""}" + ; +JOBSTATG(JOB,ROOT,PIDTYPE,PID,TYPE,STAMP,STATUS) ; Setup Job status Global + N VPRCNT,JPID S ^VPRJOB(0)=$G(^VPRJOB(0))+1 S VPRCNT=^VPRJOB(0) + S JPID=$$JPID4PID^VPRJPR(PID) S ^VPRJOB(VPRCNT,"jobId")=JOB S ^VPRJOB(VPRCNT,"jobId","\s")="" S ^VPRJOB(VPRCNT,"type")=TYPE S ^VPRJOB(VPRCNT,"jpid")=JPID + S ^VPRJOB(VPRCNT,"patientIdentifier","type")=PIDTYPE + S ^VPRJOB(VPRCNT,"patientIdentifier","value")=PID S ^VPRJOB(VPRCNT,"payload","test")="true" S ^VPRJOB(VPRCNT,"payload","test","\s")="" S ^VPRJOB(VPRCNT,"rootJobId")=ROOT @@ -61,133 +65,136 @@ S ^VPRJOB("A",JPID,TYPE,ROOT,JOB,STAMP,STATUS)=VPRCNT S ^VPRJOB("B",VPRCNT)=JPID_"^"_TYPE_"^"_ROOT_"^"_JOB_"^"_STAMP_"^"_STATUS S ^VPRJOB("C",JOB,ROOT)="" - S ^VPRJOB("D",JPID,TYPE,STAMP)="" + S ^VPRJOB("D",JPID,TYPE,STAMP,VPRCNT)="" Q + ; + ; JSONERR ;; @TEST Error code is set if JSON is mangled - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,1,"pid",PID,TYPE,STAMP,"created") S BODY(1)=BODY(1)_":" S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") - K ^TMP + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + K ^||TMP Q -JPIDERR ;; @TEST Error code is set if no JPID - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR +JPIDERR ;; @TEST Error code is set if no JPID is resolved + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="" + S PID="" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,1,"",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(231,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 231 reason code should have occurred") - K ^TMP + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(231,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 231 reason code should have occurred") + K ^||TMP Q UNKJPIDERR ;; @TEST Error code is set if JPID is unknown - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2371" + S PID="ZZUT;5" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,1,"pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 224 reason code should have occurred") - K ^TMP + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(231,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 231 reason code should have occurred") + K ^||TMP Q ROOTERR ;; @TEST Error code is set if no rootJobId - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,"",JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,"","pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(232,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 232 reason code should have occurred") - K ^TMP + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(232,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 232 reason code should have occurred") + K ^||TMP Q JOBERR ;; @TEST Error code is set if no jobId - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT("",1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT("",1,"pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(233,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 233 reason code should have occurred") - K ^TMP + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(233,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 233 reason code should have occurred") + K ^||TMP Q STATUSERR ;; @TEST Error code is set if no status - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"") + S BODY(1)=$$JOBSTAT(2,1,"pid",PID,TYPE,STAMP,"") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(234,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 234 reason code should have occurred") - K ^TMP + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(234,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 234 reason code should have occurred") + K ^||TMP Q STAMPERR ;; @TEST Error code is set if no timestamp - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP="" - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,1,"pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(0,$D(^VPRJOB),"A Job Status exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(235,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 235 reason code should have occurred") - K ^TMP + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(235,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 235 reason code should have occurred") + K ^||TMP Q VALIDERR ;; @TEST Error code is set if no the jobId and rootJobId pair doesn't match - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,STAMP,HTTPERR K ^VPRJOB S U="^" - S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,2,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,2,"pid",PID,TYPE,STAMP,"created") ; Create a collision S ^VPRJOB("C",2,1)="" S RETURN=$$SET^VPRJOB(.ARG,.BODY) ; Remove collision global to ensure check is valid K ^VPRJOB("C",2,1) D ASSERT(0,$D(^VPRJOB),"A Job Status does exists and it should not") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(236,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 236 reason code should have occurred") - K ^TMP + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(236,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 236 reason code should have occurred") + K ^||TMP Q SET1 ;; @TEST Storing one Job Status - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,1,"pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(10,$D(^VPRJOB),"A Job Status does not exist and it should") D ASSERT(10,$D(^VPRJOB(1)),"rootJobId does not exist") @@ -222,13 +229,14 @@ D ASSERT(JPID_U_TYPE_U_1_U_2_U_STAMP_U_"created",$G(^VPRJOB("B",1)),"B index doe D ASSERT(1,$D(^VPRJOB("C",2,1)),"C index does not exist correctly") Q SET2 ;; @TEST Storing two Job Status - N RETURN,BODY,ARG,U,TYPE,JPID,STAMP,HTTPERR + N RETURN,BODY,ARG,U,TYPE,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - S BODY(1)=$$JOBSTAT(2,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(2,1,"pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(10,$D(^VPRJOB),"A Job Status does not exist and it should") D ASSERT(10,$D(^VPRJOB(1)),"rootJobId does not exist") @@ -243,7 +251,7 @@ D ASSERT(JPID_U_TYPE_U_1_U_2_U_STAMP_U_"created",$G(^VPRJOB("B",1)),"B index doe D ASSERT(1,$D(^VPRJOB("C",2,1)),"C index does not exist correctly") S TYPE="jmeadows-vitals-sync-request" S STAMP=201412180711201 - S BODY(1)=$$JOBSTAT(3,1,JPID,TYPE,STAMP,"created") + S BODY(1)=$$JOBSTAT(3,1,"pid",PID,TYPE,STAMP,"created") S RETURN=$$SET^VPRJOB(.ARG,.BODY) D ASSERT(10,$D(^VPRJOB),"A Job Status does not exist and it should") D ASSERT(10,$D(^VPRJOB(2)),"rootJobId does not exist") @@ -258,13 +266,14 @@ D ASSERT(JPID_U_TYPE_U_1_U_3_U_STAMP_U_"created",$G(^VPRJOB("B",2)),"B index doe D ASSERT(1,$D(^VPRJOB("C",3,1)),"C index does not exist correctly") Q GETJPID ;; @TEST retrieve one job status by JPID - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,JPID,PID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")=JPID D GET^VPRJOB(.DATA,.ARG) D DECODE^VPRJSON("DATA","OBJECT","ERR") @@ -280,13 +289,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETICN ;; @TEST retrieve one job status by ICN - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,JPID,PID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")="1234V4321" D GET^VPRJOB(.DATA,.ARG) D DECODE^VPRJSON("DATA","OBJECT","ERR") @@ -302,13 +312,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETPID ;; @TEST retrieve one job status by PID - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,JPID,PID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")="ZZUT;3" D GET^VPRJOB(.DATA,.ARG) D DECODE^VPRJSON("DATA","OBJECT","ERR") @@ -324,13 +335,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETPIDA ;; @TEST retrieve one job status by PID (1ZZUT) - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,JPID,PID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="1ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")="1ZZUT;3" D GET^VPRJOB(.DATA,.ARG) D DECODE^VPRJSON("DATA","OBJECT","ERR") @@ -346,13 +358,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETJPIDROOT ;; @TEST retrieve one job status by JPID and rootJobId - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,JPID,PID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")=JPID S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -369,13 +382,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETICNROOT ;; @TEST retrieve one job status by ICN and rootJobId - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,JPID,ICN,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S ICN="1234V4321" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"icn",ICN,TYPE,STAMP,"created") S ARG("jpid")="1234V4321" S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -392,13 +406,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETPIDROOT ;; @TEST retrieve one job status by PID and rootJobId - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")="ZZUT;3" S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -415,13 +430,14 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETPIDAROOT ;; @TEST retrieve one job status by PID and rootJobId (1ZZUT) - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="1ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") S ARG("jpid")="1ZZUT;3" S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -438,15 +454,16 @@ D ASSERT("created",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETJPIDROOT2 ;; @TEST retrieve one job status by JPID and rootJobId with two on file - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") ; we should see the inprogress one - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"inprogress") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+1,"inprogress") S ARG("jpid")=JPID S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -463,15 +480,16 @@ D ASSERT("inprogress",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP+1,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETJPIDROOT2D ;; @TEST retrieve one job status by JPID and rootJobId with two different jobs on file - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,TYPE2,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,STAMP,TYPE2,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S TYPE2="jmeadows-vitals-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(3,1,JPID,TYPE2,STAMP+1,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(3,1,"pid",PID,TYPE2,STAMP+1,"created") S ARG("jpid")=JPID S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -496,15 +514,16 @@ D ASSERT("created",$G(OBJECT("items",2,"status")),"status is not correct") D ASSERT(STAMP+1,$G(OBJECT("items",2,"timestamp")),"timestamp is not correct") Q GETJPIDROOTC ;; @TEST retrieve one job status by JPID and rootJobId with job in completed state - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") ; we should see the completed one - D JOBSTATG(2,1,JPID,TYPE,STAMP+5,"completed") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+5,"completed") S ARG("jpid")=JPID S ARG("rootJobId")=1 D GET^VPRJOB(.DATA,.ARG) @@ -521,15 +540,16 @@ D ASSERT("completed",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP+5,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETJPIDROOTJOB ;; @TEST retrieve one job status by JPID and rootJobId and JobId - N OBJECT,DATA,ARG,U,TYPE,JPID,STAMP,TYPE2,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,STAMP,TYPE2,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S TYPE2="jmeadows-vitals-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(3,1,JPID,TYPE2,STAMP+1,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(3,1,"pid",PID,TYPE2,STAMP+1,"created") S ARG("jpid")=JPID S ARG("rootJobId")=1 S ARG("jobId")=3 @@ -560,7 +580,7 @@ D ASSERT(STAMP+1,$G(OBJECT("items",1,"timestamp")),"timestamp is not correct") ; Blows up decoding ;S BODY(1)="{ type: ""vista-ZZUT-data-poller"",patientIdentifier: { type: ""pid"", value: ""ZZUT;3"" },jpid: ""52833885-af7c-4899-90be-b3a6630b2369"",rootJobId: ""1"",jobId: ""520f4e0c-84e8-4d92-9793-23277ea357a6"",status: ""completed"",timestamp: ""1422485662841"" }" ; Quoted attributes - ; ERR from deoding + ; ERR from decoding ;S BODY(1)="{ ""type"": 'vista-ZZUT-data-poller',""patientIdentifier"": { ""type"": 'pid', ""value"": 'ZZUT;3' },""jpid"": '52833885-af7c-4899-90be-b3a6630b2369',""rootJobId"": '1',""jobId"": '520f4e0c-84e8-4d92-9793-23277ea357a6',""status"": 'completed',""timestamp"": '1422485662841' }" ; Quoted attributes and strings S BODY(1)="{ ""type"": ""vista-ZZUT-data-poller"",""patientIdentifier"": { ""type"": ""pid"", ""value"": ""ZZUT;3"" },""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369"",""rootJobId"": ""1"",""jobId"": ""520f4e0c-84e8-4d92-9793-23277ea357a6"",""status"": ""completed"",""timestamp"": ""1422485662841"" }" @@ -593,19 +613,21 @@ D ASSERT("completed",$G(OBJECT("items",1,"status")),"status is not correct") D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp is not correct") Q DELPID ;; @TEST all jobs deleted for a JPID - N OBJECT,DATA,ARG,U,TYPE,JPID,JPID2,STAMP,TYPE2 + N OBJECT,DATA,ARG,U,TYPE,PID,JPID,PID2,JPID2,STAMP,TYPE2 K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S TYPE2="jmeadows-vitals-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(3,1,JPID,TYPE2,STAMP+1,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(3,1,"pid",PID,TYPE2,STAMP+1,"created") ; create data for 2nd patient S JPID2="52833885-af7c-4899-90be-b3a6630b2370" - D JOBSTATG(4,2,JPID2,TYPE,STAMP,"created") - D JOBSTATG(5,2,JPID2,TYPE2,STAMP+1,"created") + S PID2="ZZUT;4" + D JOBSTATG(4,2,"pid",PID2,TYPE,STAMP,"created") + D JOBSTATG(5,2,"pid",PID2,TYPE2,STAMP+1,"created") ; Ensure data for the first patient exists S ARG("jpid")=JPID S ARG("rootJobId")=1 @@ -671,12 +693,12 @@ D ASSERT(0,$D(^VPRJOB(4)),"Data for Sequential Counter 4 does not exist and shou S TYPE="jmeadows-lab-sync-request" S TYPE2="jmeadows-vitals-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(3,1,JPID,TYPE2,STAMP+1,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(3,1,"pid",PID,TYPE2,STAMP+1,"created") ; create data for 2nd patient S JPID2="52833885-af7c-4899-90be-b3a6630b2370" - D JOBSTATG(4,2,JPID2,TYPE,STAMP,"created") - D JOBSTATG(5,2,JPID2,TYPE2,STAMP+1,"created") + D JOBSTATG(4,2,"pid",PID2,TYPE,STAMP,"created") + D JOBSTATG(5,2,"pid",PID2,TYPE2,STAMP+1,"created") ; Ensure data for the first patient exists S ARG("jpid")=JPID S ARG("rootJobId")=1 @@ -740,16 +762,18 @@ D ASSERT(0,$D(^VPRJOB(8)),"Data for Sequential Counter 8 does not exist and shou Q ; DELETEJPID ;; @TEST REST endpoint to delete all job statuses by JPID - N ARG,JPID,JPID2,STAMP,TYPE,RESULT + N ARG,PID,JPID,PID2,JPID2,STAMP,TYPE,RESULT K ^VPRJOB S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S JPID2="52833885-af7c-4899-90be-b3a6630b2370" + S PID2="ZZUT;4" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(1,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"created") - D JOBSTATG(3,2,JPID2,TYPE,STAMP,"created") - D JOBSTATG(4,2,JPID2,TYPE,STAMP+1,"created") + D JOBSTATG(1,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+1,"created") + D JOBSTATG(3,2,"pid",PID2,TYPE,STAMP,"created") + D JOBSTATG(4,2,"pid",PID2,TYPE,STAMP+1,"created") D ASSERT(10,$D(^VPRJOB("A",JPID)),"No jobs exist to test endpoint") S ARG("id")=JPID D DELETE^VPRJOB(.RESULT,.ARG) @@ -759,16 +783,18 @@ D ASSERT(1,$D(^VPRJOB("A",JPID2,TYPE,2,3,STAMP,"created")),"jobId 3 for JPID: "_ D ASSERT(1,$D(^VPRJOB("A",JPID2,TYPE,2,4,STAMP+1,"created")),"jobId 4 for JPID: "_JPID2_" was deleted, and should not have been") Q DELETEICN ;; @TEST REST endpoint to delete all job statuses by ICN - N ARG,JPID,JPID2,STAMP,TYPE,RESULT + N ARG,ICN,JPID,ICN2,JPID2,STAMP,TYPE,RESULT K ^VPRJOB S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S ICN="1234V4321" S JPID2="52833885-af7c-4899-90be-b3a6630b2370" + S ICN2="2345V5432" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(1,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"created") - D JOBSTATG(3,2,JPID2,TYPE,STAMP,"created") - D JOBSTATG(4,2,JPID2,TYPE,STAMP+1,"created") + D JOBSTATG(1,1,"icn",ICN,TYPE,STAMP,"created") + D JOBSTATG(2,1,"icn",ICN,TYPE,STAMP+1,"created") + D JOBSTATG(3,2,"icn",ICN2,TYPE,STAMP,"created") + D JOBSTATG(4,2,"icn",ICN2,TYPE,STAMP+1,"created") D ASSERT(10,$D(^VPRJOB("A",JPID)),"No jobs exist to test endpoint") S ARG("id")="1234V4321" D DELETE^VPRJOB(.RESULT,.ARG) @@ -778,16 +804,18 @@ D ASSERT(1,$D(^VPRJOB("A",JPID2,TYPE,2,3,STAMP,"created")),"jobId 3 for JPID: "_ D ASSERT(1,$D(^VPRJOB("A",JPID2,TYPE,2,4,STAMP+1,"created")),"jobId 4 for JPID: "_JPID2_" was deleted, and should not have been") Q DELETEPID ;; @TEST REST endpoint to delete all job statuses by PID - N ARG,JPID,JPID2,STAMP,TYPE,RESULT + N ARG,PID,JPID,PID2,JPID2,STAMP,TYPE,RESULT K ^VPRJOB S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S JPID2="52833885-af7c-4899-90be-b3a6630b2370" + S PID2="ZZUT;4" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(1,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"created") - D JOBSTATG(3,2,JPID2,TYPE,STAMP,"created") - D JOBSTATG(4,2,JPID2,TYPE,STAMP+1,"created") + D JOBSTATG(1,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+1,"created") + D JOBSTATG(3,2,"pid",PID2,TYPE,STAMP,"created") + D JOBSTATG(4,2,"pid",PID2,TYPE,STAMP+1,"created") D ASSERT(10,$D(^VPRJOB("A",JPID)),"No jobs exist to test endpoint") S ARG("id")="ZZUT;3" D DELETE^VPRJOB(.RESULT,.ARG) @@ -798,15 +826,16 @@ D ASSERT(1,$D(^VPRJOB("A",JPID2,TYPE,2,4,STAMP+1,"created")),"jobId 4 for JPID: Q ; DELJID ;; @TEST REST endpoint to delete a Job by ID - N ARG,JPID,STAMP,TYPE,RESULT + N ARG,PID,JPID,STAMP,TYPE,RESULT K ^VPRJOB S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(1,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"completed") - D JOBSTATG(3,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(4,1,JPID,TYPE,STAMP+1,"completed") + D JOBSTATG(1,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+1,"completed") + D JOBSTATG(3,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(4,1,"pid",PID,TYPE,STAMP+1,"completed") D ASSERT(10,$D(^VPRJOB("A",JPID,TYPE,1)),"No jobs exist to test endpoint") D ASSERT(1,$D(^VPRJOB("A",JPID,TYPE,1,1,STAMP,"created")),"jobId 1 does not exist, but it should") D ASSERT(1,$D(^VPRJOB("C",1,1)),"jobId 1 does not exist, but it should") @@ -828,18 +857,92 @@ D ASSERT(1,$D(^VPRJOB("A",JPID,TYPE,1,4,STAMP+1,"completed")),"jobId 4 does not D ASSERT(1,$D(^VPRJOB("C",4,1)),"jobId 4 does not exist, but it should") Q ; +GETJIDFIL ;; @TEST retrieve deleted enterprise-sync-request job status by PID (uses filter) + N OBJECT,DATA,ARG,U,TYPE,TYPE2,PID,JPID,STAMP,HTTPERR + K ^VPRJOB + S U="^" + S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" + S TYPE="enterprise-sync-request" + S TYPE2="jmeadows-lab-sync-request" + S STAMP=201412180711200 + D JOBSTATG(1,1,"pid",PID,TYPE,STAMP,"complete") + D JOBSTATG(2,1,"pid",PID,TYPE2,STAMP+1,"complete") + S ARG("jpid")="ZZUT;3" + S ARG("filter")="ilike(type,enterprise-sync-request)" + D GET^VPRJOB(.DATA,.ARG) + D DECODE^VPRJSON("DATA","OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + D ASSERT(10,$D(OBJECT),"No return from GET^VPRJOB and there should be") + D ASSERT(1,$G(OBJECT("items",1,"jobId")),"jobId does not exist, but it should") + D ASSERT(1,$G(OBJECT("items",1,"rootJobId")),"rootJobId does not exist, but it should") + D ASSERT(TYPE,$G(OBJECT("items",1,"type")),"jobType does not exist, but it should") + D ASSERT(JPID,$G(OBJECT("items",1,"jpid")),"jpid does not exist, but it should") + D ASSERT("complete",$G(OBJECT("items",1,"status")),"status does not exist, but it should") + D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist, but it should") + D ASSERT(0,$D(OBJECT("items",2)),"More items returned than expected") + D ASSERT(10,$D(^VPRJOB("D",JPID,"enterprise-sync-request",STAMP)),"enterprise-sync-request job does not exist, but it should") + D ASSERT(10,$D(^VPRJOB("D",JPID,"jmeadows-lab-sync-request",STAMP+1)),"jmeadows-lab-sync-request job does not exist, but it should") + K ARG,DATA + S ARG("jobid")=1 + D DELJID^VPRJOB(.RESULT,.ARG) + S ARG("jpid")="ZZUT;3" + S ARG("filter")="ilike(type,enterprise-sync-request)" + D GET^VPRJOB(.DATA,.ARG) + D ASSERT(0,$D(DATA),"Return from GET^VPRJOB and there shouldn't be") + D ASSERT(0,$D(^VPRJOB("D",JPID,"enterprise-sync-request",STAMP)),"enterprise-sync-request job exists, but it shouldn't") + D ASSERT(10,$D(^VPRJOB("D",JPID,"jmeadows-lab-sync-request",STAMP+1)),"jmeadows-lab-sync-request job does not exist, but it should") + QUIT + ; +GETJIDCFIL ;; @TEST retrieve deleted enterprise-sync-request job status by PID (uses complex filter) + N OBJECT,DATA,ARG,U,TYPE,TYPE2,PID,JPID,STAMP,HTTPERR + K ^VPRJOB + S U="^" + S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" + S TYPE="enterprise-sync-request" + S TYPE2="jmeadows-lab-sync-request" + S STAMP=201412180711200 + D JOBSTATG(1,1,"pid",PID,TYPE,STAMP,"complete") + D JOBSTATG(2,1,"pid",PID,TYPE2,STAMP+1,"complete") + S ARG("jpid")="ZZUT;3" + S ARG("filter")="or(eq(type,enterprise-sync-request),eq(type,jmeadows-lab-sync-request))" + D GET^VPRJOB(.DATA,.ARG) + D DECODE^VPRJSON("DATA","OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + D ASSERT(10,$D(OBJECT),"No return from GET^VPRJOB and there should be") + D ASSERT(1,$G(OBJECT("items",1,"jobId")),"jobId does not exist, but it should") + D ASSERT(1,$G(OBJECT("items",1,"rootJobId")),"rootJobId does not exist, but it should") + D ASSERT(TYPE,$G(OBJECT("items",1,"type")),"jobType does not exist, but it should") + D ASSERT(JPID,$G(OBJECT("items",1,"jpid")),"jpid does not exist, but it should") + D ASSERT("complete",$G(OBJECT("items",1,"status")),"status does not exist, but it should") + D ASSERT(STAMP,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist, but it should") + ; second item + D ASSERT(2,$G(OBJECT("items",2,"jobId")),"jobId does not exist, but it should") + D ASSERT(1,$G(OBJECT("items",2,"rootJobId")),"rootJobId does not exist, but it should") + D ASSERT(TYPE2,$G(OBJECT("items",2,"type")),"jobType does not exist, but it should") + D ASSERT(JPID,$G(OBJECT("items",2,"jpid")),"jpid does not exist, but it should") + D ASSERT("complete",$G(OBJECT("items",2,"status")),"status does not exist, but it should") + D ASSERT(STAMP+1,$G(OBJECT("items",2,"timestamp")),"timestamp does not exist, but it should") + D ASSERT(10,$D(^VPRJOB("D",JPID,"enterprise-sync-request",STAMP)),"enterprise-sync-request job does not exist, but it should") + D ASSERT(10,$D(^VPRJOB("D",JPID,"jmeadows-lab-sync-request",STAMP+1)),"jmeadows-lab-sync-request job does not exist, but it should") + QUIT + ; GETPIDFIL ;; @TEST retrieve non-completed job status by PID (uses filter) - N OBJECT,DATA,ARG,U,TYPE,TYPE2,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,TYPE2,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S TYPE2="jmeadows-vital-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"complete") - D JOBSTATG(3,2,JPID,TYPE2,STAMP,"created") - D JOBSTATG(3,2,JPID,TYPE2,STAMP+1,"error") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+1,"complete") + D JOBSTATG(3,2,"pid",PID,TYPE2,STAMP,"created") + D JOBSTATG(3,2,"pid",PID,TYPE2,STAMP+1,"error") S ARG("jpid")="ZZUT;3" S ARG("filter")="ne(status,complete)" D GET^VPRJOB(.DATA,.ARG) @@ -856,16 +959,17 @@ D ASSERT("error",$G(OBJECT("items",1,"status")),"status does not exist") D ASSERT(STAMP+1,$G(OBJECT("items",1,"timestamp")),"timestamp does not exist") Q GETPIDFILNEW ;; @TEST retrieve non-completed job status by PID (uses filter) ensure newest object - N OBJECT,DATA,ARG,U,TYPE,TYPE2,JPID,STAMP,HTTPERR + N OBJECT,DATA,ARG,U,TYPE,TYPE2,PID,JPID,STAMP,HTTPERR K ^VPRJOB S U="^" S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="ZZUT;3" S TYPE="jmeadows-lab-sync-request" S STAMP=201412180711200 - D JOBSTATG(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG(2,1,JPID,TYPE,STAMP+1,"error") - D JOBSTATG(3,2,JPID,TYPE,STAMP+4,"created") - D JOBSTATG(3,2,JPID,TYPE,STAMP+5,"complete") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG(2,1,"pid",PID,TYPE,STAMP+1,"error") + D JOBSTATG(3,2,"pid",PID,TYPE,STAMP+4,"created") + D JOBSTATG(3,2,"pid",PID,TYPE,STAMP+5,"complete") S ARG("jpid")="ZZUT;3" S ARG("filter")="ne(status,complete)" D GET^VPRJOB(.DATA,.ARG) diff --git a/VPRJTODM.m b/VPRJTODM.m old mode 100755 new mode 100644 index d582467..d3dd058 --- a/VPRJTODM.m +++ b/VPRJTODM.m @@ -27,10 +27,10 @@ S BODY(1)=BODY(1)_":" ; Send it to the URL S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETIDRR ;; @TEST Error code is set if no ID N RETURN,BODY,ARG,HTTPERR @@ -38,31 +38,31 @@ D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason S BODY(1)=$$SITEOD("","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(220,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(220,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Try with a non existant _id field S BODY(1)="{""ZZUT"": ""20150127-1000""}" S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(220,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(220,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SET1 ;; @TEST Store one operational data mutable N RETURN,BODY,ARG,HTTPERR S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup ^VPRJODM K ^VPRJODM("ZZUT") I $G(^VPRJODM(0))>0 S ^VPRJODM(0)=^VPRJODM(0)-1 @@ -72,33 +72,33 @@ D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Run it again with a new lastUpdate time S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1500") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1500",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Run it again with a new lastUpdate time that is smaller S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-25") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-25",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup ^VPRJODM K ^VPRJODM("ZZUT") I $G(^VPRJODM(0))>0 S ^VPRJODM(0)=^VPRJODM(0)-3 @@ -109,10 +109,10 @@ D ASSERT("20150127-25",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field w D DEL^VPRJODM(.DATA,.ARGS) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup vars K DATA,OBJECT,ERR,ARGS ; Try with a blank _id @@ -120,10 +120,10 @@ S ARGS("_id")="" D DEL^VPRJODM(.DATA,.ARGS) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q DEL ;; @TEST Delete operational data mutable N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -131,11 +131,11 @@ D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now delete it @@ -145,7 +145,7 @@ S ARGS("_id")="ZZUT" D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q LEN ;; @TEST Get number of operational data mutable N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -153,42 +153,42 @@ D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now get length D LEN^VPRJODM(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error Occured") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") D ASSERT(1,$G(OBJECT("length")),"The total number of objects doesn't match1") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K OBJECT,DATA,ERR,ARGS ; Create operational data mutable S BODY(1)=$$SITEOD("ZZUT1","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"A operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now get length D LEN^VPRJODM(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error Occured") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") D ASSERT(2,$G(OBJECT("length")),"The total number of objects doesn't match2") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup ^VPRJODM K ^VPRJODM("ZZUT") K ^VPRJODM("ZZUT1") @@ -200,10 +200,10 @@ D ASSERT(2,$G(OBJECT("length")),"The total number of objects doesn't match2") D GET^VPRJODM(.DATA,.ARGS) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,OBJECT,ARGS ; Try with a null id @@ -211,20 +211,20 @@ S ARGS("_id")="" D GET^VPRJODM(.DATA,.ARGS) D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q GETJSONERR ;; Error code is set if encoding to JSON fails N DATA,ARGS,OBJECT,HTTPERR S ARGS("_id")="ZZUT" D GET^VPRJODM(.DATA,.ARGS) D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q GET ;; @TEST Get operational data mutable N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -232,11 +232,11 @@ D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored @@ -245,22 +245,22 @@ S ARGS("_id")="ZZUT" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("20150127-1000",$G(OBJECT("lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR ; Create operational data mutable update S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1500") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1500",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored update @@ -269,22 +269,22 @@ S ARGS("_id")="ZZUT" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("20150127-1500",$G(OBJECT("lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR ; Create second operational data mutable S BODY(1)=$$SITEOD("ZZUT1","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT1")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT1",$G(^VPRJODM("ZZUT1","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT1","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get second operational data mutable @@ -293,11 +293,11 @@ S ARGS("_id")="ZZUT1" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJODM("ZZUT1")),"operational data mutable does not exists and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT1",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("20150127-1000",$G(OBJECT("lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; leave these around so they can be killed in the next test Q GETFILTER ;; @TEST Get operational data mutable with filter @@ -306,22 +306,22 @@ D ASSERT("20150127-1000",$G(OBJECT("lastUpdate")),"returned data for lastUpdate S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJODM("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Create operational data mutable update S BODY(1)=$$SITEOD("ZZUT1","lastUpdate","20150127-1500") S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT1")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT1",$G(^VPRJODM("ZZUT1","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1500",$G(^VPRJODM("ZZUT1","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored update @@ -329,13 +329,13 @@ S ARGS("filter")="ne(_id,abc)" D GET^VPRJODM(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("items",1,"_id")),"returned data for the wrong _id") D ASSERT("20150127-1000",$G(OBJECT("items",1,"lastUpdate")),"returned data for lastUpdate didn't match") D ASSERT("ZZUT1",$G(OBJECT("items",2,"_id")),"returned data for the wrong _id") D ASSERT("20150127-1500",$G(OBJECT("items",2,"lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR ; Get second operational data mutable @@ -343,11 +343,11 @@ S ARGS("filter")="ne(_id,ZZUT)" D GET^VPRJODM(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT1",$G(OBJECT("items",1,"_id")),"returned data for the wrong _id") D ASSERT("20150127-1500",$G(OBJECT("items",1,"lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; leave these around so they can be killed in the next test Q CLR ;; @TEST Clear ALL operational data mutable @@ -358,7 +358,7 @@ D ASSERT(0,$D(^VPRJODM("ZZUT")),"A operational data mutable exists and it should D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") D ASSERT(10,$D(^VPRJODM),"Global not cleared") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q REAL ;; @TEST with realistic data N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -366,12 +366,12 @@ D ASSERT(10,$D(^VPRJODM),"Global not cleared") S BODY(1)="{""_id"": ""ZZUT"",""timestamp"": ""3150126-724"",""uid"": ""urn:va:vprupdate:ZZUT""}" S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("3150126-724",$G(^VPRJODM("ZZUT","timestamp")),"The timestamp field was not stored correctly") D ASSERT("urn:va:vprupdate:ZZUT",$G(^VPRJODM("ZZUT","uid")),"The uid field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored @@ -380,12 +380,12 @@ S ARGS("_id")="ZZUT" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("3150126-724",$G(OBJECT("timestamp")),"returned data for timestamp didn't match") D ASSERT("urn:va:vprupdate:ZZUT",$G(OBJECT("uid")),"The uid field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup VPRJODM D CLR^VPRJODM(.DATA,.ARGS) Q @@ -395,12 +395,12 @@ D ASSERT("urn:va:vprupdate:ZZUT",$G(OBJECT("uid")),"The uid field was not stored S BODY(1)="{""_id"": ""ZZUT"",""timestamp"": ""3150126-724"",""uid"": ""urn:va:vprupdate:ZZUT""}" S RETURN=$$SET^VPRJODM(.ARG,.BODY) D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJODM("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("3150126-724",$G(^VPRJODM("ZZUT","timestamp")),"The timestamp field was not stored correctly") D ASSERT("urn:va:vprupdate:ZZUT",$G(^VPRJODM("ZZUT","uid")),"The uid field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored @@ -409,12 +409,12 @@ S ARGS("_id")="ZZUT" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJODM("ZZUT")),"operational data mutable does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("3150126-724",$G(OBJECT("timestamp")),"returned data for timestamp didn't match") D ASSERT("urn:va:vprupdate:ZZUT",$G(OBJECT("uid")),"The uid field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup VPRJODM K DATA,ARGS D CLR^VPRJODM(.DATA,.ARGS) diff --git a/VPRJTP01.m b/VPRJTP01.m old mode 100755 new mode 100644 index 6fb58df..311c072 --- a/VPRJTP01.m +++ b/VPRJTP01.m @@ -79,3 +79,39 @@ UTST5 ;; sample object for patient 8 ;;{"uid":"urn:va:utestc:93EF:-8:5","name":"sample object 5","color":"orange","serialNumber":523,"rate":3,"clinical":false,"stay":{"started":"201406012330"},"updated":"201407012330","stampTime":"8"} ;;zzzzz +DOCORDER1 ;; sample document data for case-insensitive order testing for patient 7 + ;;{"uid":"urn:va:document:93EF;-7:1","pid":"93EF;-7","author":"MACINTOSH,JOHN","authorDisplayName":"Macintosh,John","authorUid":"urn:va:user:93EF:19840124","stampTime":"8","datetime":20071231125256} + ;;zzzzz +DOCORDER2 ;; sample document data for case-insensitive order testing for patient 7 + ;;{"uid":"urn:va:document:93EF;-7:2","pid":"93EF;-7","author":"MACMULLIN,ED","authorDisplayName":"MacMullin,Ed","authorUid":"urn:va:user:93EF:19851120","stampTime":"8","datetime":20000521095449} + ;;zzzzz +EHMPDOCS1;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:consult:93EF;-7:264","pid":"93EF;-7","kind":"Consult","statusName":"COMPLETE","dateTime":"20000521094224","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS2;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:consult:93EF;-7:265","kind":"Consult","pid":"93EF;-7","statusName":"INCOMPLETE","dateTime":"20000521094225","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS3;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:surgery:93EF;-7:266","kind":"Surgery","pid":"93EF;-7","statusName":"COMPLETE","dateTime":"20000521094225","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS4;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:surgery:93EF;-7:267","kind":"Surgery","pid":"93EF;-7","statusName":"INCOMPLETE","dateTime":"20000521094225","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS5;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:image:93EF;-7:268","kind":"Image","pid":"93EF;-7","statusName":"COMPLETE","dateTime":"20000521094225","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS6;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:image:93EF;-7:269","kind":"Image","pid":"93EF;-7","statusName":"INCOMPLETE","dateTime":"20000521094226","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS7;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:procedure:93EF;-7:270","kind":"Procedure","pid":"93EF;-7","statusName":"COMPLETE","dateTime":"20000521094225","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS8;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:procedure:93EF;-7:271","kind":"Procedure","pid":"93EF;-7","statusName":"INCOMPLETE","dateTime":"20000521094226","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS9;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:document:93EF;-7:270","pid":"93EF;-7","statusName":"COMPLETE","dateTime":"20000521094225","stampTime":"20000523160148"} + ;;zzzzz +EHMPDOCS10;;sampledocumentdataforehmp-documentsindex + ;;{"uid":"urn:va:document:93EF;-7:271","pid":"93EF;-7","statusName":"INCOMPLETE","dateTime":"20000521094226","stampTime":"20000523160148"} + ;;zzzzz diff --git a/VPRJTP02.m b/VPRJTP02.m old mode 100755 new mode 100644 diff --git a/VPRJTP03.m b/VPRJTP03.m old mode 100755 new mode 100644 index cdcb35d..0d0d1b8 --- a/VPRJTP03.m +++ b/VPRJTP03.m @@ -49,7 +49,7 @@ ;;zzzzz ; SRV6 ;; sample entry #1 - ;;{"patient":"-7","facility":"Camp Other","uid":"urn:va:utesta:9999:-7:6","localId":"a6","stampTime":"76"} + ;;{"patient":"-7","facility":"Camp Other","uid":"urn:va:utesta:PORT:-7:6","localId":"a6","stampTime":"76"} ;;zzzzz SRV7 ;; sample entry #2 ;;{"patient":"-7","facility":"Camp Master","uid":"urn:va:utesta:93EF:-7:7","localId":"a7","stampTime":"77"} diff --git a/VPRJTP04.m b/VPRJTP04.m new file mode 100644 index 0000000..3d61eb5 --- /dev/null +++ b/VPRJTP04.m @@ -0,0 +1,16 @@ +VPRJTP04 ;V4W/DLW -- Sample patient data for POST queries + ; + ; POST filter data for POST query tests (VPRJTQP) +POSTFILTER ;; test POST query data (1004 characters) - over the 1000 character limit some browsers and proxies have + ;;{"filter":"or(between(\"stampTime\",\"72\",\"74\"),between(\"overallStart\",\"20060530\",\"20090125\")), + ;;or(ilike(\"uid\",\"%urn:va:med:93EF:-7:17%\"),ilike(\"uid\",\"%urn:va:med:93EF:-7:18%\"), + ;;ilike(\"uid\",\"%urn:va:med:93EF:-7:16%\"),or(ilike(\"facilityName\",\"%Master%\"),ilike(\"facilityName\",\"%Camp%\"), + ;;ilike(\"facilityName\",\"%CAMP MASTER%\"))),or(ilike(\"sig\",\"%EVERY DAY AT NOON%\"),ilike(\"sig\",\"%TAKE ONE TABLET BY%\"), + ;;ilike(\"sig\",\"%EVERY MORNING%\"),or(ilike(\"vaStatus\",\"%DISCONTINUED%\"),ilike(\"vaStatus\",\"%ACTIVE%\"), + ;;ilike(\"vaStatus\",\"%CONTINUED%\"))),or(ilike(\"kind\",\"%Medication, Outpatient%\"),ilike(\"kind\",\"%Medication, Non-VA%\"), + ;;ilike(\"kind\",\"%Medication, Out%\"),or(ilike(\"qualifiedName\",\"%METFORMIN%\"),ilike(\"qualifiedName\",\"%WARFARIN%\"), + ;;ilike(\"qualifiedName\",\"%ASPIRIN%\"))),or(between(\"overallStop\",\"20060601\",\"20070602\"), + ;;between(\"overallStop\",\"20070801\",\"20071230\"),between(\"overallStop\",\"20080401\",\"20090401\"), + ;;or(ilike(\"medStatus\",\"%urn:sct:73425007%\"),ilike(\"medStatus\",\"%urn:sct:55561003%\"), + ;;ilike(\"medStatus\",\"%urn:sct:55512004%\")))"} + ;;zzzzz diff --git a/VPRJTPATID.m b/VPRJTPATID.m old mode 100755 new mode 100644 index 139f32c..8018b1a --- a/VPRJTPATID.m +++ b/VPRJTPATID.m @@ -1,23 +1,23 @@ VPRJTPATID ;KRM/CJE -- Unit Tests for GET/PUT Patient Identifiers and JPID utils - ;;1.0;JSON DATA STORE;;Dec 16, 2014 ; ; Endpoints tested ;GET vpr/jpid/{jpid} PIDS^VPRJPR ;PUT vpr/jpid/{jpid} ASSOCIATE^VPRJPR ;PUT vpr/jpid ASSOCIATE^VPRJPR ;DELETE vpr/jpid/{jpid} DISASSOCIATE^VPRJPR + ;DELETE vpr/{pid} DELPT^VPRJPR ;POST vpr/jpid/query JPIDQUERY^VPRJPR ; STARTUP ; Run once before all tests K ^VPRPTJ K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q SHUTDOWN ; Run once after all tests K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSERT(EXPECT,ACTUAL,MSG) ; for convenience D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) @@ -26,141 +26,143 @@ PATIDS ; Setup patient identifiers S ^VPRPTX("count","patient","patient")=1 S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","9E7A;3")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","C877;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","1234V4321")="" - S ^VPRPTJ("JPID","9E7A;3")="52833885-af7c-4899-90be-b3a6630b2369" - S ^VPRPTJ("JPID","C877;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" S ^VPRPTJ("JPID","1234V4321")="52833885-af7c-4899-90be-b3a6630b2369" Q ; PATIDSNICN ; Setup patient identifiers S ^VPRPTX("count","patient","patient")=1 S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","9E7A;3")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","C877;3")="" - S ^VPRPTJ("JPID","9E7A;3")="52833885-af7c-4899-90be-b3a6630b2369" - S ^VPRPTJ("JPID","C877;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" Q ; NEWJPID ;; @TEST Creating a new JPID N JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S JPID=$$JPID^VPRJPR D NE^VPRJT("",$G(JPID),"JPID not created") - D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existance index not created") - D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index not created") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"JPID;"_JPID)),"Patient JPID not found in identifier list") + D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existence index not created but should be") + D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index not created but should be") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"JPID;"_JPID)),"Patient JPID not found in identifier list but should be") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q IDXJPID ;; @TEST Index a new JPID with one identifier N JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S JPID=$$JPID^VPRJPR - D JPIDIDX^VPRJPR(JPID,"9E7A;3") + D JPIDIDX^VPRJPR(JPID,"SITE;3") D NE^VPRJT("",$G(JPID),"JPID not created") - D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existance index not created") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"Patient identifier forward (JPID -> PID/ICN) index not updated correctly") + D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existence index not created but should be") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"Patient identifier forward (JPID -> PID/ICN) index not updated correctly") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"JPID;"_JPID)),"Patient identifier forward (JPID -> JPID;{JPID}) index not updated correctly") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"Patient identifier reverse (PID/ICN -> JPID) index not updated correctly") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"Patient identifier reverse (PID/ICN -> JPID) index not updated correctly") D ASSERT(JPID,$G(^VPRPTJ("JPID","JPID;"_JPID)),"Patient identifier reverse (JPID;{JPID} -> JPID index not updated correctly") - D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index not created") + D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index not created but should be") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q IDXJPID2 ;; @TEST Index a new JPID with two identifiers N JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S JPID=$$JPID^VPRJPR - D JPIDIDX^VPRJPR(JPID,"9E7A;3") + D JPIDIDX^VPRJPR(JPID,"SITE;3") D JPIDIDX^VPRJPR(JPID,"1234V4321") D NE^VPRJT("",$G(JPID),"JPID not created") - D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existance index not created") - D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index not created") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"Patient identifier forward (JPID -> PID/ICN) index not updated correctly") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"Patient identifier reverse (PID/ICN -> JPID) index not updated correctly") + D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existence index not created but should be") + D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index not created but should be") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"Patient identifier forward (JPID -> PID/ICN) index not updated correctly") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"Patient identifier reverse (PID/ICN -> JPID) index not updated correctly") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"Patient identifier forward (JPID -> PID/ICN) index not updated correctly") D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"Patient identifier reverse (PID/ICN -> JPID) index not updated correctly") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q DELJPID ;; @TEST Delete one Patient identifier from JPID Index N JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" - D JPIDDIDX^VPRJPR(JPID,"9E7A;3") - D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existance does not exist and should") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"Patient identifier forward (JPID -> PID/ICN index exists") - D ASSERT(0,$D(^VPRPTJ("JPID","9E7A;3")),"Patient identifier reverse (PID/ICN -> JPID index exists") + D JPIDDIDX^VPRJPR(JPID,"SITE;3") + D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existence does not exist and should") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"Patient identifier forward (JPID -> PID/ICN) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"Patient identifier reverse (PID/ICN -> JPID) index exists but should not") D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index incorrect") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q + ; DELJPID2 ;; @TEST Delete two Patient identifiers from JPID Index N JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" - D JPIDDIDX^VPRJPR(JPID,"9E7A;3") + D JPIDDIDX^VPRJPR(JPID,"SITE;3") D JPIDDIDX^VPRJPR(JPID,"1234V4321") - D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existance index does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"Patient identifier forward (JPID -> PID/ICN index exists") - D ASSERT(0,$D(^VPRPTJ("JPID","9E7A;3")),"Patient identifier reverse (PID/ICN -> JPID index exists") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"Patient identifier forward (JPID -> PID/ICN index exists") - D ASSERT(0,$D(^VPRPTJ("JPID","1234v4321")),"Patient identifier reverse (PID/ICN -> JPID index exists") + D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID existence index does not exist but should") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"Patient identifier forward (JPID -> PID/ICN) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"Patient identifier reverse (PID/ICN -> JPID) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"Patient identifier forward (JPID -> PID/ICN) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID","1234v4321")),"Patient identifier reverse (PID/ICN -> JPID) index exists but should not") D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"Patient count index incorrect") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP - Q + K ^||TMP + QUIT + ; DELJPIDA ;; @TEST Delete all Patient identifiers from JPID Index N JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" - D JPIDDIDX^VPRJPR(JPID,"9E7A;3") + D JPIDDIDX^VPRJPR(JPID,"SITE;3") D JPIDDIDX^VPRJPR(JPID,"1234V4321") - D JPIDDIDX^VPRJPR(JPID,"C877;3") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID)),"JPID existance index exists") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"Patient identifier forward (JPID -> PID/ICN index exists") - D ASSERT(0,$D(^VPRPTJ("JPID","9E7A;3")),"Patient identifier reverse (PID/ICN -> JPID index exists") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"Patient identifier forward (JPID -> PID/ICN index exists") - D ASSERT(0,$D(^VPRPTJ("JPID","1234v4321")),"Patient identifier reverse (PID/ICN -> JPID index exists") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"C877;3")),"Patient identifier forward (JPID -> PID/ICN index exists") - D ASSERT(0,$D(^VPRPTJ("JPID","C877;3")),"Patient identifier reverse (PID/ICN -> JPID index exists") + D JPIDDIDX^VPRJPR(JPID,"SITE;3") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID)),"JPID existence index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"Patient identifier forward (JPID -> PID/ICN) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"Patient identifier reverse (PID/ICN -> JPID) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"Patient identifier forward (JPID -> PID/ICN) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID","1234v4321")),"Patient identifier reverse (PID/ICN -> JPID) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"Patient identifier forward (JPID -> PID/ICN) index exists but should not") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"Patient identifier reverse (PID/ICN -> JPID) index exists but should not") D ASSERT(0,$G(^VPRPTX("count","patient","patient")),"Patient count index incorrect") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q JPID4PID ;; @TEST Retrieving a JPID for a PID/ICN N JPID,GJPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S GJPID="52833885-af7c-4899-90be-b3a6630b2369" - S JPID=$$JPID4PID^VPRJPR("9E7A;3") + S JPID=$$JPID4PID^VPRJPR("SITE;3") D ASSERT(GJPID,JPID,"JPIDs do not match (PID1)") - S JPID=$$JPID4PID^VPRJPR("C877;3") + S JPID=$$JPID4PID^VPRJPR("SITE;3") D ASSERT(GJPID,JPID,"JPIDs do not match (PID2)") S JPID=$$JPID4PID^VPRJPR("1234V4321") D ASSERT(GJPID,JPID,"JPIDs do not match (ICN)") @@ -168,31 +170,31 @@ D ASSERT(GJPID,JPID,"JPIDs do not match (ICN)") D ASSERT("",JPID,"JPID found when it shoudn't be") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q PID4JPID ;; @TEST Retrieving a list of PIDs for a JPID N JPID,PIDS K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" D PID4JPID^VPRJPR(.PIDS,JPID) D ASSERT("1234V4321",$G(PIDS(1)),"ICN not found") - D ASSERT("9E7A;3",$G(PIDS(2)),"9E7A;3 PID not found") - D ASSERT("C877;3",$G(PIDS(3)),"C877;3 PID not found") + D ASSERT("SITE;3",$G(PIDS(2)),"SITE;3 PID not found") + D ASSERT("SITE;3",$G(PIDS(3)),"SITE;3 PID not found") D ASSERT("",$G(PIDS(4)),"Too many PIDS returned") D PID4JPID^VPRJPR(.PIDS,"") D ASSERT(0,$D(PIDS),"PIDS array exists") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ICN4JPID ;; @TEST Retrieving an ICN for a JPID N JPID,ICN K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" S ICN=$$ICN4JPID^VPRJPR(JPID) @@ -201,194 +203,207 @@ D ASSERT("1234V4321",$G(ICN),"ICN not found") D ASSERT("",$G(ICN),"ICN found") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q PIDSNJPID ;; @TEST Error code is set if no jpid passed N DATA,ARG,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S ARG("jpid")="" D PIDS^VPRJPR(.DATA,.ARG) D ASSERT(0,$D(DATA),"Return from PIDS^VPRJPR and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(222,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 222 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(222,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 222 reason code should have occurred") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q PIDSNFJPID ;; @TEST Error code is set if no jpid found N DATA,ARG,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S ARG("jpid")="DOD;1234V4321" D PIDS^VPRJPR(.DATA,.ARG) D ASSERT(0,$D(DATA),"Return from PIDS^VPRJPR and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 224 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(224,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 224 reason code should have occurred") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q PIDSJPID ;; @TEST GET PIDs for a JPID N DATA,OBJECT,ARG,ERR,HTTPERR,JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" S ARG("jpid")=JPID D PIDS^VPRJPR(.DATA,.ARG) - D DECODE^VPRJSON("^TMP($J)","OBJECT","ERR") + D DECODE^VPRJSON("^||TMP($J)","OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") D ASSERT(1,$D(DATA),"No return from PIDS^VPRJPR and there should be") D ASSERT(JPID,$G(OBJECT("jpid")),"JPID doesn't exist") D ASSERT("1234V4321",$G(OBJECT("patientIdentifiers",1)),"ICN 1234V4321 does not exit") - D ASSERT("9E7A;3",$G(OBJECT("patientIdentifiers",2)),"PID 9E7A;3 does not exit") - D ASSERT("C877;3",$G(OBJECT("patientIdentifiers",3)),"PID C877;3 does not exit") + D ASSERT("SITE;3",$G(OBJECT("patientIdentifiers",2)),"PID SITE;3 does not exit") + D ASSERT("SITE;3",$G(OBJECT("patientIdentifiers",3)),"PID SITE;3 does not exit") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q PIDSPID ;; @TEST GET PIDs for a PID N DATA,OBJECT,ARG,ERR,HTTPERR,JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" - S ARG("jpid")="9E7A;3" + S ARG("jpid")="SITE;3" D PIDS^VPRJPR(.DATA,.ARG) - D DECODE^VPRJSON("^TMP($J)","OBJECT","ERR") + D DECODE^VPRJSON("^||TMP($J)","OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") D ASSERT(1,$D(DATA),"No return from PIDS^VPRJPR and there should be") D ASSERT(JPID,$G(OBJECT("jpid")),"JPID doesn't exist") D ASSERT("1234V4321",$G(OBJECT("patientIdentifiers",1)),"ICN 1234V4321 does not exit") - D ASSERT("9E7A;3",$G(OBJECT("patientIdentifiers",2)),"PID 9E7A;3 does not exit") - D ASSERT("C877;3",$G(OBJECT("patientIdentifiers",3)),"PID C877;3 does not exit") + D ASSERT("SITE;3",$G(OBJECT("patientIdentifiers",2)),"PID SITE;3 does not exit") + D ASSERT("SITE;3",$G(OBJECT("patientIdentifiers",3)),"PID SITE;3 does not exit") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q PIDSICN ;; @TEST GET PIDs for an ICN N DATA,OBJECT,ARG,ERR,HTTPERR,JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" S ARG("jpid")="1234V4321" D PIDS^VPRJPR(.DATA,.ARG) - D DECODE^VPRJSON("^TMP($J)","OBJECT","ERR") + D DECODE^VPRJSON("^||TMP($J)","OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") D ASSERT(1,$D(DATA),"No return from PIDS^VPRJPR and there should be") D ASSERT(JPID,$G(OBJECT("jpid")),"JPID doesn't exist") D ASSERT("1234V4321",$G(OBJECT("patientIdentifiers",1)),"ICN 1234V4321 does not exit") - D ASSERT("9E7A;3",$G(OBJECT("patientIdentifiers",2)),"PID 9E7A;3 does not exit") - D ASSERT("C877;3",$G(OBJECT("patientIdentifiers",3)),"PID C877;3 does not exit") + D ASSERT("SITE;3",$G(OBJECT("patientIdentifiers",2)),"PID SITE;3 does not exit") + D ASSERT("SITE;3",$G(OBJECT("patientIdentifiers",3)),"PID SITE;3 does not exit") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCEJSON ;; @TEST Associate JSON decode error N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""ASDF;123""],""test}" S JPID=$$ASSOCIATE^VPRJPR(.ARG,.BODY) D ASSERT("",JPID,"Return from ASSOCIATE^VPRJPR and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCEMISMATCH ;; @TEST Associate Mismatch JPID between body and passed argument error N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""ASDF;123""],""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" S ARG("jpid")="52833885-af7c-4899-90be-b3a6630b2370" S JPID=$$ASSOCIATE^VPRJPR(.ARG,.BODY) D ASSERT("",JPID,"Return from ASSOCIATE^VPRJPR and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") - D ASSERT(205,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") + D ASSERT(205,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCENOID ;; @TEST Associate no patIdentifiers Object error N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" S JPID=$$ASSOCIATE^VPRJPR(.ARG,.BODY) D ASSERT("",JPID,"Return from ASSOCIATE^VPRJPR and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") - D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") + D ASSERT(211,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q + ; ASSOCEASSOCP ;; @TEST Associate JPID with PID already known error - N BODY,ARG,ERR,JPID,HTTPERR + N BODY,ARG,ERR,JPID,HTTPERR,NJPID,PATJPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP - S BODY(1)="{""patientIdentifiers"": [""9E7A;3""]}" + K ^||TMP + S BODY(1)="{""patientIdentifiers"": [""SITE;3""]}" D PATIDS S JPID=$$ASSOCIATE^VPRJPR(.ARG,.BODY) D ASSERT("",JPID,"Return from ASSOCIATE^VPRJPR and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") - D ASSERT(223,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") - K ^VPRPTJ("JPID") - K ^VPRPTX("count","patient","patient") - K ^TMP - Q + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") + D ASSERT(223,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") + D ASSERT("JPID Collision Detected",$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"message")),"Error message is not correct") + ; Check to see if another JPID was created and set up in ^VPRPTJ("JPID"), as it should not be + ; Test by checking for JPID format, ignoring the JPID set up in PATIDS. Should get back an "" + S NJPID="",PATJPID="52833885-af7c-4899-90be-b3a6630b2369" + F S NJPID=$O(^VPRPTJ("JPID",NJPID)) Q:(NJPID="")!((NJPID?8LN1"-"4LN1"-"4LN1"-"4LN1"-"12LN)&(NJPID'=PATJPID)) + D ASSERT("",NJPID,"ASSOCIATE set up a new JPID, with a JPID collision, which should never happen") + ; Now confirm that the VHIC JPID was also not created + S NJPID="" + F S NJPID=$O(^VPRPTJ("JPID",NJPID)) Q:(NJPID="")!((NJPID?1"JPID;"8LN1"-"4LN1"-"4LN1"-"4LN1"-"12LN)&(NJPID'=PATJPID)) + D ASSERT("",NJPID,"ASSOCIATE set up a new JPID, with a JPID collision, which should never happen") + D ASSERT(1,$G(^VPRPTX("count","patient","patient")),"The patient count should not have incremented") + K ^VPRPTJ("JPID") + K ^VPRPTX("count","patient","patient") + K ^||TMP + QUIT + ; ASSOCEASSOCI ;; @TEST Associate JPID with ICN already known error N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""1234V4321""]}" D PATIDS S JPID=$$ASSOCIATE^VPRJPR(.ARG,.BODY) D ASSERT("",JPID,"Return from ASSOCIATE^VPRJPR and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") - D ASSERT(223,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"Error code does not exist") + D ASSERT(223,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"Error reason does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCNPID ;; @TEST Associate PID with new JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP - S BODY(1)="{""patientIdentifiers"": [""9E7A;3""]}" + K ^||TMP + S BODY(1)="{""patientIdentifiers"": [""SITE;3""]}" S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) D ASSERT(1,$D(JPID),"No return from ASSOCIATE^VPRJPR and there should be") D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCNICN ;; @TEST Associate ICN with new JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""1234V4321""]}" S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) D ASSERT(1,$D(JPID),"No return from ASSOCIATE^VPRJPR and there should be") @@ -398,35 +413,35 @@ D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does n D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCNALL ;; @TEST Associate array of Patient Identifiers with new JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP - S BODY(1)="{""patientIdentifiers"": [""1234V4321"",""9E7A;3"",""C877;3"",""DOD;1234V4321""]}" + K ^||TMP + S BODY(1)="{""patientIdentifiers"": [""1234V4321"",""SITE;3"",""SITE;3"",""DOD;1234V4321""]}" S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) D ASSERT(1,$D(JPID),"No return from ASSOCIATE^VPRJPR and there should be") D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"DOD;1234V4321")),"JPID index for DOD;1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","DOD;1234V4321")),"PID index for DOD;1234V4321 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCPID ;; @TEST Associate PID with existing JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""DOD;1234V4321""],""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" D PATIDS S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) @@ -435,21 +450,21 @@ D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"DOD;1234V4321")),"JPID index for DOD;1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","DOD;1234V4321")),"PID index for DOD;1234V4321 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCICN ;; @TEST Associate ICN with existing JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""1234V4321""],""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" D PATIDSNICN S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) @@ -458,65 +473,65 @@ D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCBID ;; @TEST Associate a Bad patient identifer with existing JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""000000003""],""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" D PATIDSNICN S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) D ASSERT(1,$D(JPID),"No return from ASSOCIATE^VPRJPR and there should be") D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"A 400 error should have occurred") - D ASSERT(230,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 230 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"A 400 error should have occurred") + D ASSERT(230,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 230 reason code should have occurred") D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"000000003")),"JPID index for 000000003 does not exist") D ASSERT("",$G(^VPRPTJ("JPID","000000003")),"PID index for 000000003 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCBID2 ;; @TEST Associate a Bad patient identifer with existing JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""ASDF123"",""112233""],""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" D PATIDSNICN S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) D ASSERT(1,$D(JPID),"No return from ASSOCIATE^VPRJPR and there should be") D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"A 400 error should have occurred") - D ASSERT(230,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 230 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"A 400 error should have occurred") + D ASSERT(230,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 230 reason code should have occurred") D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"ASDF123")),"JPID index for ASDF123 does not exist") D ASSERT("",$G(^VPRPTJ("JPID","ASDF123")),"PID index for ASDF123 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCALL ;; @TEST Associate array of Patient Identifiers with existing JPID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""1234V4321"",""DOD;1234V4321"",""VLER;1234V4321""],""jpid"": ""52833885-af7c-4899-90be-b3a6630b2369""}" D PATIDSNICN S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) @@ -525,25 +540,25 @@ D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"DOD;1234V4321")),"JPID index for DOD;1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","DOD;1234V4321")),"PID index for DOD;1234V4321 does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"VLER;1234V4321")),"JPID index for VLER;1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","VLER;1234V4321")),"PID index for VLER;1234V4321 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q ASSOCALLP ;; @TEST Associate array of Patient Identifiers with existing JPID using a PID N BODY,ARG,ERR,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP S BODY(1)="{""patientIdentifiers"": [""1234V4321"",""DOD;1234V4321"",""VLER;1234V4321""]}" - S ARG("jpid")="9E7A;3" + S ARG("jpid")="SITE;3" D PATIDSNICN S JPID=$P($$ASSOCIATE^VPRJPR(.ARG,.BODY),"/",4) D ASSERT(1,$D(JPID),"No return from ASSOCIATE^VPRJPR and there should be") @@ -551,17 +566,17 @@ D ASSERT(10,$D(^VPRPTJ("JPID")),"JPID index does not exist") D ASSERT(11,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(JPID,$G(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(JPID,$G(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"DOD;1234V4321")),"JPID index for DOD;1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","DOD;1234V4321")),"PID index for DOD;1234V4321 does not exist") D ASSERT(1,$D(^VPRPTJ("JPID",JPID,"VLER;1234V4321")),"JPID index for VLER;1234V4321 does not exist") D ASSERT(JPID,$G(^VPRPTJ("JPID","VLER;1234V4321")),"PID index for VLER;1234V4321 does not exist") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q DISAPID DISAICN @@ -571,110 +586,138 @@ D ASSERT(JPID,$G(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not N BODY,ARG,ERR,RETURN,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" S ARG("jpid")=JPID D DISASSOCIATE^VPRJPR(.BODY,.ARG) - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error returned from DISASSOCIATE^VPRJPR") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error returned from DISASSOCIATE^VPRJPR") D ASSERT(0,$D(^VPRPTJ("JPID")),"JPID index exists") D ASSERT(0,$D(^VPRPTJ("JSON")),"Patient data JSON exists") D ASSERT(0,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(0,$D(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"A lastAccessTime data node exists and should not") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q DISAALLP ;; @TEST Disassociate JPID (Delete JPID and Patient Data) using PID N BODY,ARG,ERR,RETURN,JPID,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" - S ARG("jpid")="9E7A;3" + S ARG("jpid")="SITE;3" D DISASSOCIATE^VPRJPR(.BODY,.ARG) - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"Error returned from DISASSOCIATE^VPRJPR") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error returned from DISASSOCIATE^VPRJPR") D ASSERT(0,$D(^VPRPTJ("JPID")),"JPID index exists") D ASSERT(0,$D(^VPRPTJ("JSON")),"Patient data JSON exists") D ASSERT(0,$D(^VPRPTJ("JPID",JPID)),"JPID does not exist") D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 does not exist") D ASSERT(0,$D(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"9E7A;3")),"JPID index for 9E7A;3 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID","9E7A;3")),"PID index for 9E7A;3 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"C877;3")),"JPID index for C877;3 does not exist") - D ASSERT(0,$D(^VPRPTJ("JPID","C877;3")),"PID index for C877;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 does not exist") + D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"A lastAccessTime data node exists and should not") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q DISAEJPID ;; @TEST Disassociate No JPID passed error N BODY,ARG,ERR,HTTPERR,JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S ARG("jpid")="" D DISASSOCIATE^VPRJPR(.BODY,.ARG) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(222,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 222 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(222,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 222 reason code should have occurred") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP Q DISAEJPIDU ;; @TEST Disassociate JPID Unknown error N BODY,ARG,ERR,HTTPERR,JPID K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S ARG("jpid")="52833885-af7c-4899-90be-b3a6630b2370" D DISASSOCIATE^VPRJPR(.BODY,.ARG) - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 224 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(224,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 224 reason code should have occurred") K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP + Q + ; +DELALL ;; @TEST Delete PID (Delete PID and Patient Data) + N BODY,ARG,ERR,RETURN,JPID,HTTPERR + K ^VPRPTJ("JPID") + K ^VPRPTX("count","patient","patient") + K ^||TMP + D PATIDS + S PID="SITE;3" + S JPID=$$JPID4PID^VPRJPR(PID) + S ARG("pid")=PID + D DELPT^VPRJPR(.BODY,.ARG) + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"Error returned from DELPT^VPRJPR") + D ASSERT(0,$D(^VPRPTJ("JPID")),"JPID index exists and should not") + D ASSERT(0,$D(^VPRPTJ("JSON")),"Patient data JSON exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID)),"JPID exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"1234V4321")),"JPID index for 1234V4321 exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID","1234V4321")),"PID index for 1234V4321 exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID",JPID,"SITE;3")),"JPID index for SITE;3 exists and should not") + D ASSERT(0,$D(^VPRPTJ("JPID","SITE;3")),"PID index for SITE;3 exists and should not") + D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"A lastAccessTime data node exists and should not") + K ^VPRPTJ("JPID") + K ^VPRPTX("count","patient","patient") + K ^||TMP Q ; INVJPIDQ ;; @TEST JPID QUERY with an invalid query N RETURN,ARGS,BODY,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S BODY="{""TEST"":1}" S RETURN=$$JPIDQUERY^VPRJPR(.ARGS,.BODY) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(242,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 242 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(242,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 242 reason code should have occurred") Q ; KNOWNJPIDQ ;; @TEST JPID Query with all known PIDs N RETURN,ARGS,BODY,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS - S BODY="{""patientIdentifiers"":[""9E7A;3"",""C877;3"",""1234V4321""]}" + S BODY="{""patientIdentifiers"":[""SITE;3"",""SITE;3"",""1234V4321""]}" S RETURN=$$JPIDQUERY^VPRJPR(.ARGS,.BODY) - D ASSERT("",$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") + D ASSERT("",$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") D ASSERT("52833885-af7c-4899-90be-b3a6630b2369",$P(RETURN,"/",4),"returned JPID doesn't match expected value") Q ; -1UNKNOWNJPIDQ ;; @TEST JPID Query with 1 unknown PID +UNKNOWNJPIDQ ;; @TEST JPID Query with 1 unknown PID N RETURN,ARGS,BODY,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS - S BODY="{""patientIdentifiers"":[""9E7A;3"",""ABCD;3"",""1234V4321""]}" + S BODY="{""patientIdentifiers"":[""SITE;3"",""ABCD;3"",""1234V4321""]}" S RETURN=$$JPIDQUERY^VPRJPR(.ARGS,.BODY) - D ASSERT("",$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") + D ASSERT("",$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") D ASSERT("52833885-af7c-4899-90be-b3a6630b2369",$P(RETURN,"/",4),"returned JPID doesn't match expected value") Q ; @@ -682,29 +725,29 @@ D ASSERT("52833885-af7c-4899-90be-b3a6630b2369",$P(RETURN,"/",4),"returned JPID N RETURN,ARGS,BODY,HTTPERR K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S BODY="{""patientIdentifiers"":[""1234;3"",""ABCD;3"",""4321V1234""]}" S RETURN=$$JPIDQUERY^VPRJPR(.ARGS,.BODY) - D ASSERT("",$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") + D ASSERT("",$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") D ASSERT("",RETURN,"should have received an empty string and didn't") Q ; -1COLJPIDQ ;; @TEST JPID Query with 1 JPID collision +COLJPIDQ ;; @TEST JPID Query with 1 JPID collision N RETURN,ARGS,BODY,HTTPERR,TMP K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S TMP=$I(^VPRPTX("count","patient","patient")) S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2370")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2370","ASDF;3")="" S ^VPRPTJ("JPID","ASDF;3")="52833885-af7c-4899-90be-b3a6630b2370" ; - S BODY="{""patientIdentifiers"":[""9E7A;3"",""ASDF;3"",""C877;3""]}" + S BODY="{""patientIdentifiers"":[""SITE;3"",""ASDF;3"",""SITE;3""]}" S RETURN=$$JPIDQUERY^VPRJPR(.ARGS,.BODY) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") - D ASSERT(223,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 242 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") + D ASSERT(223,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 242 reason code should have occurred") D ASSERT("",RETURN,"should have received an empty string and didn't") Q ; @@ -712,7 +755,7 @@ D ASSERT("",RETURN,"should have received an empty string and didn't") N RETURN,ARGS,BODY,HTTPERR,TMP K ^VPRPTJ("JPID") K ^VPRPTX("count","patient","patient") - K ^TMP + K ^||TMP D PATIDS S TMP=$I(^VPRPTX("count","patient","patient")) S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2370")="" @@ -723,9 +766,9 @@ D ASSERT("",RETURN,"should have received an empty string and didn't") S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2371","4321V1234")="" S ^VPRPTJ("JPID","4321V1234")="52833885-af7c-4899-90be-b3a6630b2371" ; - S BODY="{""patientIdentifiers"":[""9E7A;3"",""ASDF;3"",""4321V1234""]}" + S BODY="{""patientIdentifiers"":[""SITE;3"",""ASDF;3"",""4321V1234""]}" S RETURN=$$JPIDQUERY^VPRJPR(.ARGS,.BODY) - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") - D ASSERT(223,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 242 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should not have occured") + D ASSERT(223,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 242 reason code should have occurred") D ASSERT("",RETURN,"should have received an empty string and didn't") Q ; diff --git a/VPRJTPDI.m b/VPRJTPDI.m new file mode 100644 index 0000000..c64907d --- /dev/null +++ b/VPRJTPDI.m @@ -0,0 +1,72 @@ +VPRJTPDI ;AFS/MBS -- Integration tests for document indexes + ; +STARTUP ; Run once before all tests + N I,TAGS + F I=1:1:5 S TAGS(I)="MED"_I_"^VPRJTP02" + D BLDPT^VPRJTX(.TAGS) + K TAGS + F I=1:1:3 S TAGS(I)="UTST"_I_"^VPRJTP01" + D ADDDATA^VPRJTX(.TAGS,VPRJTPID) + K TAGS + F I=1:1:10 S TAGS(I)="EHMPDOCS"_I_"^VPRJTP01" + D ADDDATA^VPRJTX(.TAGS,VPRJTPID) + Q +SHUTDOWN ; Run once after all tests + D CLRPT^VPRJTX + Q +ASSERT(EXPECT,ACTUAL,MSG) ; for convenience + D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) + Q + ; +TMP2ARY(ARY) ; convert JSON object in ^||TMP($J) to array + ; ARY must be passed by reference + N SIZE,PREAMBLE + S HTTPREQ("store")="vpr" ; normally this gets set in RESPOND^VPRJRSP + D PAGE^VPRJRUT("^||TMP($J)",0,999,.SIZE,.PREAMBLE) + N SRC,N,I,J + S N=0,SRC(N)="{""data"":{""totalItems"":"_^||TMP($J,"total")_",""items"":[" + S I="" F S I=$O(^||TMP($J,$J,I)) Q:I="" D + . I I S SRC(N)=SRC(N)_"," + . S J=0 F S J=$O(^||TMP($J,$J,I,J)) Q:'J D + . . S N=N+1,SRC(N)=^||TMP($J,$J,I,J) + S N=N+1,SRC(N)="]}}" + D DECODE^VPRJSON("SRC","ARY","ERR") + D ASSERT(0,$G(ERR(0),0),"JSON conversion error") + Q +EHMPSETIF ;; @TEST unit test setif condition for ehmp-documents index + N HTTPERR,JSON,OBJ + S HTTPREQ("store")="vpr" + D GETDATA^VPRJTX("EHMPDOCS1","VPRJTP01",.JSON) + D DECODE^VPRJSON("JSON","OBJ") + D ASSERT(1,$$EHMPDOC^VPRJFPS(.OBJ),"ehmp-documents setif failed to pass good consult data") + K JSON,OBJ + D GETDATA^VPRJTX("EHMPDOCS2","VPRJTP01",.JSON) + D DECODE^VPRJSON("JSON","OBJ") + D ASSERT(0,$$EHMPDOC^VPRJFPS(.OBJ),"ehmp-documents setif failed to filter bad consult data") + K JSON,OBJ + D GETDATA^VPRJTX("EHMPDOCS9","VPRJTP01",.JSON) + D DECODE^VPRJSON("JSON","OBJ") + D ASSERT(1,$$EHMPDOC^VPRJFPS(.OBJ),"ehmp-documents setif failed to pass good document data") + K JSON,OBJ + D GETDATA^VPRJTX("EHMPDOCS10","VPRJTP01",.JSON) + D DECODE^VPRJSON("JSON","OBJ") + D ASSERT(1,$$EHMPDOC^VPRJFPS(.OBJ),"ehmp-documents setif failed to pass good incomplete document data") + Q + ; +EHMPDOCS ;; @TEST integration test ehmp-documents + N HTTPERR,ARGS,RET,EHMP,DOCS,MATCH + K ^||TMP($J) + S ARGS("pid")="93EF;-7",ARGS("indexName")="docs-view",ARGS("filter")="not(and(in(""kind"",[""Consult"",""Imaging"",""Procedure""]),ne(""statusName"",""COMPLETE"")))" + D INDEX^VPRJPR(.RET,.ARGS) + D TMP2ARY(.DOCS) + K ARGS S ARGS("pid")="93EF;-7",ARGS("indexName")="ehmp-documents" + K ^||TMP($J) D INDEX^VPRJPR(.RET,.ARGS) + D TMP2ARY(.EHMP) + D ASSERT($G(DOCS("data","totalItems")),$G(EHMP("data","totalItems"))) + S MATCH=1 + F I=1:1:$G(DOCS("data","totalItems")) D + . I $G(EHMP("data","items",I,"uid"))'=$G(DOCS("data","items",I,"uid")) D + . . S MATCH=0 + D ASSERT(1,MATCH,"ehmp-documents return does not match docs-view return with filter") + Q + ; diff --git a/VPRJTPL.m b/VPRJTPL.m index 033a88c..c0bd209 100644 --- a/VPRJTPL.m +++ b/VPRJTPL.m @@ -57,7 +57,7 @@ Q ; KILLIDS - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRPTJ("JPID","ZZUT;3") K ^VPRPTJ("JPID","ZZUT1;3") diff --git a/VPRJTPQ.m b/VPRJTPQ.m old mode 100755 new mode 100644 index 30efea1..643b795 --- a/VPRJTPQ.m +++ b/VPRJTPQ.m @@ -8,6 +8,8 @@ K TAGS F I=1:1:3 S TAGS(I)="UTST"_I_"^VPRJTP01" D ADDDATA^VPRJTX(.TAGS,VPRJTPID) + F I=1:1:2 S TAGS(I)="DOCORDER"_I_"^VPRJTP01" + D ADDDATA^VPRJTX(.TAGS,VPRJTPID) Q SHUTDOWN ; Run once after all tests D CLRPT^VPRJTX @@ -16,17 +18,17 @@ D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) Q ; -TMP2ARY(ARY) ; convert JSON object in ^TMP($J) to array +TMP2ARY(ARY) ; convert JSON object in ^||TMP($J) to array ; ARY must be passed by reference N SIZE,PREAMBLE S HTTPREQ("store")="vpr" ; normally this gets set in RESPOND^VPRJRSP - D PAGE^VPRJRUT("^TMP($J)",0,999,.SIZE,.PREAMBLE) + D PAGE^VPRJRUT("^||TMP($J)",0,999,.SIZE,.PREAMBLE) N SRC,N,I,J - S N=0,SRC(N)="{""data"":{""totalItems"":"_^TMP($J,"total")_",""items"":[" - S I="" F S I=$O(^TMP($J,$J,I)) Q:I="" D + S N=0,SRC(N)="{""data"":{""totalItems"":"_^||TMP($J,"total")_",""items"":[" + S I="" F S I=$O(^||TMP($J,$J,I)) Q:I="" D . I I S SRC(N)=SRC(N)_"," - . S J=0 F S J=$O(^TMP($J,$J,I,J)) Q:'J D - . . S N=N+1,SRC(N)=^TMP($J,$J,I,J) + . S J=0 F S J=$O(^||TMP($J,$J,I,J)) Q:'J D + . . S N=N+1,SRC(N)=^||TMP($J,$J,I,J) S N=N+1,SRC(N)="]}}" D DECODE^VPRJSON("SRC","ARY","ERR") D ASSERT(0,$G(ERR(0),0),"JSON conversion error") @@ -49,7 +51,7 @@ D ASSERT($C(255,255,255),STOP(1)) Q JSON ;; @TEST json formatting N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-ingredient-name","METFOR*",,,"uid") D ASSERT(0,$D(HTTPERR)) N ARY D TMP2ARY(.ARY) @@ -59,7 +61,7 @@ D ASSERT(3,ARY("data","totalItems")) Q TIME ;; @TEST time based query N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-time","20060101..20061231") D ASSERT(0,$D(HTTPERR)) N ARY D TMP2ARY(.ARY) @@ -70,7 +72,7 @@ D ASSERT("250 MG",ARY("data","items",3,"dosages",1,"dose")) Q TIMEASC ;; @TEST ascending order N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-time","20060101..20061231","asc",4) N ARY D TMP2ARY(.ARY) D ASSERT(3,ARY("data","totalItems")) @@ -83,7 +85,7 @@ D ASSERT("500 MG",ARY("data","items",3,"dosages",1,"dose")) Q TIMEIF ;; @TEST setif on time index N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"utest-time") N ARY,I D TMP2ARY(.ARY) @@ -92,7 +94,7 @@ D ASSERT(3,ARY("data","totalItems")) Q SORTSTOP ;; @TEST sorting by the stop time on time based index N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-time","","overallStop asc") N ARY D TMP2ARY(.ARY) D ASSERT("20060318",ARY("data","items",1,"overallStop")) ; ascending @@ -101,38 +103,38 @@ D ASSERT("urn:va:med:93EF:-7:18068",ARY("data","items",5,"uid")) Q ATTR ;; @TEST attribute query N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-ingredient-name","METFOR*") N ARY D TMP2ARY(.ARY) D ASSERT(3,ARY("data","totalItems")) - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-ingredient-name","[ASPIRIN..METFORMIN]") K ARY D TMP2ARY(.ARY) D ASSERT(4,ARY("data","totalItems")) Q ATTRLIM ;; @TEST attribute query with bail limits on return N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-ingredient-name","METFOR*",,1) N ARY D TMP2ARY(.ARY) D ASSERT(1,ARY("data","totalItems")) Q LIST ;; @TEST list based query N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"med-active-outpt") N ARY D TMP2ARY(.ARY) D ASSERT(2,ARY("data","totalItems")) Q LAST ;; @TEST most recent query N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QLAST^VPRJPQ(VPRJTPID,"med-qualified-name") N ARY D TMP2ARY(.ARY) D ASSERT("urn:va:med:93EF:-7:18069",ARY("data","items",1,"uid")) D ASSERT("urn:va:med:93EF:-7:17203",ARY("data","items",2,"uid")) D ASSERT("urn:va:med:93EF:-7:18068",ARY("data","items",3,"uid")) - K ^TMP($J) + K ^||TMP($J) D QLAST^VPRJPQ(VPRJTPID,"med-class-code","urn:vadc:HS502, urn:vadc:CN103, urn:vadc:XX000") K ARY D TMP2ARY(.ARY) D ASSERT(2,ARY("data","totalItems")) @@ -141,7 +143,7 @@ D ASSERT("urn:va:med:93EF:-7:18068",ARY("data","items",2,"uid")) Q MATCH ;; match query (DISABLED for NOW) N HTTPERR - K ^TMP($J) + K ^||TMP($J) ;D QINDEX^VPRJPQ(VPRJTPID,"condition.bleedingrisk") ;N ARY D TMP2ARY(.ARY) D ASSERT(1,$G(ARY("data","totalItems"))) @@ -149,27 +151,27 @@ D ASSERT("urn:vadc:BL110",$G(ARY("data","items",1,"products",1,"drugClassCode")) Q TALLY ;; @TEST tally items by PID N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QTALLY^VPRJPQ(VPRJTPID,"kind") N ARY - D DECODE^VPRJSON("^TMP($J)","ARY","ERR") + D DECODE^VPRJSON("^||TMP($J)","ARY","ERR") D ASSERT(0,$G(ERR(0),0),"JSON conversion error") D ASSERT(2,ARY("data","totalItems")) D ASSERT(4,ARY("data","items",2,"count")) Q TALLY2 ;; @TEST get tally items by JPID N HTTPERR,RESULT,ARGS,ARY - K ^TMP($J) + K ^||TMP($J) S ARGS("pid")=VPRJTPID S ARGS("countName")="collection" D COUNT^VPRJPR(.RESULT,.ARGS) D DECODE^VPRJSON(RESULT,"ARY","ERR") I $D(ERR) D ASSERT(0,$D(ERR),"JSON conversion error") ZWRITE ERR Q - D ASSERT(3,$G(ARY("data","items",3,"count")),"count not found or wrong") + D ASSERT(3,$G(ARY("data","items",4,"count")),"count not found or wrong") Q UID ;; @TEST get uid N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QKEY^VPRJPQ(VPRJTPID,"urn:va:med:93EF:-7:17266") N ARY D TMP2ARY(.ARY) D ASSERT("402924;O",ARY("data","items",1,"localId")) @@ -177,15 +179,76 @@ D ASSERT("urn:vuid:4023979",ARY("data","items",1,"products",1,"ingredientCode")) Q ORDER ;; @TEST sorting on different field N HTTPERR - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"medication","","qualifiedName") N ARY D TMP2ARY(.ARY) D ASSERT("ASPIRIN",ARY("data","items",1,"qualifiedName")) - K ^TMP($J) + K ^||TMP($J) D QINDEX^VPRJPQ(VPRJTPID,"medication","","qualifiedName desc") K ARY D TMP2ARY(.ARY) D ASSERT("WARFARIN",ARY("data","items",1,"qualifiedName")) Q +ORDERCI ;; @TEST sorting by case sensitive or case insensitive + N HTTPERR,ARY + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName asc cs") + K ARY D TMP2ARY(.ARY) + D ASSERT("MacMullin,Ed",ARY("data","items",1,"authorDisplayName"),"Passing 'cs' in 'order' should make sorting case sensitive.") + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName cs asc") + K ARY D TMP2ARY(.ARY) + D ASSERT("MacMullin,Ed",ARY("data","items",1,"authorDisplayName"),"Passing 'cs' in 'order' should make sorting case sensitive.") + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName cs") + K ARY D TMP2ARY(.ARY) + D ASSERT("MacMullin,Ed",ARY("data","items",1,"authorDisplayName"),"Passing 'cs' in 'order' should make sorting case sensitive.") + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName") + K ARY D TMP2ARY(.ARY) + D ASSERT("MacMullin,Ed",ARY("data","items",1,"authorDisplayName"),"Default sorting should be case sensitive.") + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName asc ci") + K ARY D TMP2ARY(.ARY) + D ASSERT("Macintosh,John",ARY("data","items",1,"authorDisplayName"),"Passing 'ci' in 'order' should make sorting case insensitive.") + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName ci asc") + K ARY D TMP2ARY(.ARY) + D ASSERT("Macintosh,John",ARY("data","items",1,"authorDisplayName"),"Passing 'ci' in 'order' should make sorting case insensitive.") + K ^||TMP($J) + D QINDEX^VPRJPQ(VPRJTPID,"document",,"authorDisplayName ci") + K ARY D TMP2ARY(.ARY) + D ASSERT("Macintosh,John",ARY("data","items",1,"authorDisplayName"),"Passing 'ci' in 'order' should make sorting case insensitive.") + Q +SETORDER ;; @TEST handle sorting modifiers in any order + N HTTPERR,ORDER,INDEX,TEMPLATE + S INDEX="document",TEMPLATE="" + M INDEX=^VPRMETA("index",INDEX,"common") + ; the collate spec for this index is defined as 'V', which flips the sort direction modfier and makes the tests confusing + ; so we'll remove that for our test + S INDEX("collate",1)="" + S ORDER="authorDisplayName desc ci" + D SETORDER^VPRJCO(.ORDER) + D ASSERT(-1,ORDER(1,"dir"),"Failed to get desc sorting modifier when first") + D ASSERT(1,ORDER(1,"nocase"),"Failed to get case insensitive sorting modifier when second") + K ORDER S ORDER="authorDisplayName ci desc" + D SETORDER^VPRJCO(.ORDER) + D ASSERT(-1,ORDER(1,"dir"),"Failed to get desc sorting modifier when second") + D ASSERT(1,ORDER(1,"nocase"),"Failed to get case insensitive sorting modifier when first") + K ORDER S ORDER="ci desc" + D SETORDER^VPRJCO(.ORDER) + D ASSERT("1-1",ORDER(1,"nocase")_ORDER(1,"dir"),"Failed to parse default sort field with case insentive modifier first") + K ORDER S ORDER="desc ci" + D SETORDER^VPRJCO(.ORDER) + D ASSERT("1-1",ORDER(1,"nocase")_ORDER(1,"dir"),"Failed to parse default sort field with case insentive modifier second") + K ORDER S ORDER="ci" + D SETORDER^VPRJCO(.ORDER) + D ASSERT($P(INDEX("order")," "),$P(ORDER," "),"Failed to get default sort field") + D ASSERT("1",ORDER(1,"nocase"),"Failed to parse default sort field with case insentive modifier only") + K ORDER S ORDER="desc" + D SETORDER^VPRJCO(.ORDER) + D ASSERT($P(INDEX("order")," "),$P(ORDER," "),"Failed to get default sort field") + D ASSERT(-1,ORDER(1,"dir"),"Failed to parse default sort field with direction modifier only") + Q 1 ; do one test D STARTUP,SORTSTOP,SHUTDOWN Q diff --git a/VPRJTPR.m b/VPRJTPR.m old mode 100755 new mode 100644 index e85a01b..9f14755 --- a/VPRJTPR.m +++ b/VPRJTPR.m @@ -1,5 +1,4 @@ VPRJTPR ;SLC/KCM -- Integration tests for RESTful queries - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; STARTUP ; Run once before all tests N I,TAGS @@ -11,7 +10,7 @@ K ^VPRPTJ K ^VPRPT K ^VPRMETA("JPID") - K ^TMP + K ^||TMP Q SETUP ; Run before each test K HTTPREQ,HTTPERR,HTTPRSP @@ -23,6 +22,29 @@ D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) Q ; + ; POST data for POST query tests +POSTDATA1 ;; test POST query data for TIMERNG + ;;{"range":"20060101..20061231"} + ;;zzzzz +POSTDATA2 ;; test POST query data for LAST + ;;{"range":"Metformin, Aspirin Tab"} + ;;zzzzz +POSTDATA3 ;; test POST query data for ORDASC + ;;{"order":"qualifiedName asc"} + ;;zzzzz +POSTDATA4 ;; test POST query data for ORDDESC + ;;{"order":"qualifiedName DESC"} + ;;zzzzz +POSTDATA5 ;; test POST query data for ORDEMPTY + ;;{"order":"stopped"} + ;;zzzzz +POSTDATA6 ;; test POST query data for FILTER + ;;{"filter":"gt(\"orders[].fillsRemaining\",4)"} + ;;zzzzz +POSTDATA7 ;; test POST query data for FINDPAR + ;;{"filter":"eq(\"products[].ingredientName\",\"METFORMIN\") eq(\"dosages[].dose\",\"250 MG\")"} + ;;zzzzz + ; TIMERNG ;; @TEST query for range of time ;;{"data":{"updated":20120517174918,"totalItems":3,"items":[{ N ROOT,JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -43,6 +65,20 @@ D ASSERT(1,TIME>PTIME) D DATA2ARY^VPRJTX(.JSON) D ASSERT(3,$G(JSON("data","totalItems"))) D ASSERT("METFORMIN",$G(JSON("data","items",3,"products",1,"ingredientName"))) + ; test POST query version + K HTTPER,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTDATA1","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(3,$G(JSON("data","totalItems"))) + D ASSERT("METFORMIN",$G(JSON("data","items",3,"products",1,"ingredientName"))) Q LAST ;; @TEST query for last instance of items in list N ROOT,JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -64,6 +100,21 @@ D ASSERT(1,TIME>PTIME) D ASSERT(2,$G(JSON("data","totalItems"))) D ASSERT("urn:va:med:93EF:-7:18069",$G(JSON("data","items",1,"uid"))) D ASSERT("urn:va:med:93EF:-7:18068",$G(JSON("data","items",2,"uid"))) + ; test POST query version + K HTTPERR,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/last/med-ingredient-name?query=true","POSTDATA2","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(2,$G(JSON("data","totalItems"))) + D ASSERT("urn:va:med:93EF:-7:18069",$G(JSON("data","items",1,"uid"))) + D ASSERT("urn:va:med:93EF:-7:18068",$G(JSON("data","items",2,"uid"))) Q ORDASC ;; @TEST query to return in different order N ROOT,JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -83,6 +134,19 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(1,TIME>PTIME) D DATA2ARY^VPRJTX(.JSON) D ASSERT("WARFARIN",$G(JSON("data","items",5,"qualifiedName"))) + ; test POST query version + K HTTPER,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/medication?query=true","POSTDATA3","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT("WARFARIN",$G(JSON("data","items",5,"qualifiedName"))) Q ORDDESC ;; @TEST query to return in different order N ROOT,JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -102,6 +166,19 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(1,TIME>PTIME) D DATA2ARY^VPRJTX(.JSON) D ASSERT("WARFARIN",$G(JSON("data","items",1,"qualifiedName"))) + ; test POST query version + K HTTPER,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/medication?query=true","POSTDATA4","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT("WARFARIN",$G(JSON("data","items",1,"qualifiedName"))) Q ORDEMPTY ;; @TEST "order by" where field includes empty string N ROOT,JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -122,6 +199,20 @@ D ASSERT(1,TIME>PTIME) D DATA2ARY^VPRJTX(.JSON) D ASSERT("",$G(JSON("data","items",1,"stopped"))) D ASSERT("20080128",$G(JSON("data","items",5,"stopped"))) + ; test POST query version + K HTTPERR,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/medication?query=true","POSTDATA5","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT("",$G(JSON("data","items",1,"stopped"))) + D ASSERT("20080128",$G(JSON("data","items",5,"stopped"))) Q FILTER ;; @TEST filter to return based on criteria ;;{"data":{"updated":20120517174918,"totalItems":3,"items":[{ @@ -144,6 +235,20 @@ D ASSERT(1,TIME>PTIME) D ASSERT(1,$G(JSON("data","totalItems"))) D ASSERT("urn:va:med:93EF:-7:17203",$G(JSON("data","items",1,"uid"))) ;D SHOWRSP^VPRJTX(ROOT) + ; test POST query version + K HTTPERR,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/medication/?query=true","POSTDATA6","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(1,$G(JSON("data","totalItems"))) + D ASSERT("urn:va:med:93EF:-7:17203",$G(JSON("data","items",1,"uid"))) Q GETUID ;; @TEST getting an object by UID only N JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -182,7 +287,7 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(1,TIME>PTIME) D DATA2ARY^VPRJTX(.JSON) D ASSERT(6,$G(JSON("data","totalItems"))) - D ASSERT(0,$D(^TMP($J,$J))) + D ASSERT(0,$D(^||TMP($J,$J))) S VPRJTPID1=$$JPID4PID^VPRJPR(VPRJTPID) ; Cache is disable ;D ASSERT(10,$D(^VPRTMP($$HASH^VPRJRUT("vpr/index/"_VPRJTPID1_"/every////")))) @@ -239,6 +344,20 @@ D ASSERT(1,TIME>PTIME) D DATA2ARY^VPRJTX(.JSON) D ASSERT(1,$G(JSON("data","totalItems"))) D ASSERT("urn:va:med:93EF:-7:16982",$G(JSON("data","items",1,"uid"))) + ; test POST query version + K HTTPERR,JSON,PTIME,TIME + S TIME=^VPRMETA("JPID",VPRJPID,"lastAccessTime") + H 1 + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/find/med?query=true","POSTDATA7","VPRJTPR") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + S PTIME=TIME + H 1 + S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) + D ASSERT(1,TIME>PTIME) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(1,$G(JSON("data","totalItems"))) + D ASSERT("urn:va:med:93EF:-7:16982",$G(JSON("data","items",1,"uid"))) Q FINDLIKE ;; @TEST finding using like() N JSON,ERR,HTTPERR,PTIME,TIME,VPRJPID @@ -334,6 +453,7 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(0,$D(^VPRPT(VPRJPID,MYPID))) D ASSERT(0,$D(^VPRPTJ("JSON",VPRJPID,MYPID))) D ASSERT(0,$D(^VPRPTI(VPRJPID,MYPID))) + D ASSERT(0,$D(^VPRMETA("JPID",VPRJPID,"lastAccessTime"))) Q NOICN ;; @TEST add patient without ICN N HTTPERR,JSON,PTIME,TIME,VPRJPID @@ -380,6 +500,7 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(0,$D(^VPRPT(VPRJPID,"93EF;-9"))) D ASSERT(0,$D(^VPRPTJ("JSON",VPRJPID,"93EF;-9"))) D ASSERT(0,$D(^VPRPTI(VPRJPID,"93EF;-9"))) + D ASSERT(0,$D(^VPRMETA("JPID",VPRJPID,"lastAccessTime"))) Q ADDICN ;; @TEST add an ICN where the patient did not previously have one N HTTPERR,JSON,PTIME,TIME,VPRJPID @@ -503,6 +624,7 @@ D ASSERT(0,$G(HTTPERR)) D ASSERT(0,$D(^VPRPT(VPRJPID,MYPID))) D ASSERT(0,$D(^VPRPTJ("JSON",VPRJPID,MYPID))) D ASSERT(0,$D(^VPRPTI(VPRJPID,MYPID))) + D ASSERT(0,$D(^VPRMETA("JPID",VPRJPID,"lastAccessTime"))) Q DELCLTN ;; @TEST delete collection via REST N HTTPERR,X,PTIME,TIME,VPRJPID @@ -527,35 +649,50 @@ D ASSERT(1,TIME>PTIME) N HTTPERR,PID1,PID2,JPID1,JPID2 S PID1="93EF;-7" S PID2="93DD;-7" - S JPID1=$$JPID4PID^VPRJPR(PID1) - S JPID2=$$JPID4PID^VPRJPR(PID2) + S JPID=$$JPID4PID^VPRJPR(PID1) D SETPUT^VPRJTX("/vpr","DEMOG7","VPRJTP01") - D SETPUT^VPRJTX("/vpr","NUMFAC","VPRJTP01") - D ASSERT(10,$D(^VPRPT(JPID1,PID1))) - D ASSERT(10,$D(^VPRPTJ("JSON",JPID1,PID1))) - D ASSERT(10,$D(^VPRPTJ("TEMPLATE",JPID1,PID1))) - D ASSERT(1,^VPRPTI(JPID1,PID1,"tally","collection","patient")) - D ASSERT(10,$D(^VPRPT(JPID2,PID2))) - D ASSERT(10,$D(^VPRPTJ("JSON",JPID2,PID2))) - D ASSERT(10,$D(^VPRPTJ("TEMPLATE",JPID2,PID2))) - D ASSERT(1,^VPRPTI(JPID2,PID2,"tally","collection","patient")) + ; Kill non-primary sites to test lastAccessTime + K ^VPRPTJ("JPID","1HDR;-7") + K ^VPRPTJ("JPID","1HDR;-777V123777") + K ^VPRPTJ("JPID","HDR1;-777V123777") + K ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","1HDR;-7") + K ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","1HDR;-777V123777") + K ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","HDR1;-777V123777") + D ASSERT(10,$D(^VPRPT(JPID,PID1))) + D ASSERT(10,$D(^VPRPTJ("JSON",JPID,PID1))) + D ASSERT(10,$D(^VPRPTJ("TEMPLATE",JPID,PID1))) + D ASSERT(1,^VPRPTI(JPID,PID1,"tally","collection","patient")) + D ASSERT(10,$D(^VPRPT(JPID,PID2))) + D ASSERT(10,$D(^VPRPTJ("JSON",JPID,PID2))) + D ASSERT(10,$D(^VPRPTJ("TEMPLATE",JPID,PID2))) + D ASSERT(1,^VPRPTI(JPID,PID2,"tally","collection","patient")) D SETDEL^VPRJTX("/vpr/site/93EF") D RESPOND^VPRJRSP D ASSERT(0,$G(HTTPERR)) - D ASSERT(0,$D(^VPRPT(JPID1,PID1))) - D ASSERT(0,$D(^VPRPTJ("JSON",JPID1,PID1))) - D ASSERT(0,$D(^VPRPTJ("TEMPLATE",JPID1,PID1))) - D ASSERT(0,^VPRPTI(JPID1,PID1,"tally","collection","patient")) - D ASSERT(10,$D(^VPRPT(JPID2,PID2))) - D ASSERT(10,$D(^VPRPTJ("JSON",JPID2,PID2))) - D ASSERT(10,$D(^VPRPTJ("TEMPLATE",JPID2,PID2))) - D ASSERT(10,$D(^VPRPTI(JPID2,PID2))) + D ASSERT(0,$D(^VPRPT(JPID,PID1))) + D ASSERT(0,$D(^VPRPTJ("JSON",JPID,PID1))) + D ASSERT(0,$D(^VPRPTJ("TEMPLATE",JPID,PID1))) + D ASSERT(0,^VPRPTI(JPID,PID1,"tally","collection","patient")) + D ASSERT(10,$D(^VPRPT(JPID,PID2))) + D ASSERT(10,$D(^VPRPTJ("JSON",JPID,PID2))) + D ASSERT(10,$D(^VPRPTJ("TEMPLATE",JPID,PID2))) + D ASSERT(10,$D(^VPRPTI(JPID,PID2))) + D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) D SETDEL^VPRJTX("/vpr/site/93DD") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D ASSERT(0,$D(^VPRPT(JPID,PID1))) + D ASSERT(0,$D(^VPRPTJ("JSON",JPID,PID1))) + D ASSERT(0,$D(^VPRPTJ("TEMPLATE",JPID,PID1))) + D ASSERT(0,$D(^VPRPT(JPID,PID2))) + D ASSERT(0,$D(^VPRPTJ("JSON",JPID,PID2))) + D ASSERT(0,$D(^VPRPTJ("TEMPLATE",JPID,PID2))) + D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime"))) Q GETDMOG1 ;; @TEST try to get demographics when none on file ICN ; Ensure requried variables are clean N HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Setup Patient Asssociations S ^VPRPTJ("JPID","8765;-1")="52833885-af7c-4899-90be-b3a6630b2373" S ^VPRPTJ("JPID","-222V123222")="52833885-af7c-4899-90be-b3a6630b2373" @@ -566,12 +703,12 @@ D ASSERT(10,$D(^VPRPTI(JPID2,PID2))) D SETGET^VPRJTX("vpr/mpid/-222V123222") D RESPOND^VPRJRSP D ASSERT(HTTPERR,400,"HTTPERR isn't set and should be") - D ASSERT($G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),225,"Incorrect error reason passed to client") + D ASSERT($G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),225,"Incorrect error reason passed to client") Q GETDMOG2 ;; @TEST try to get demographics when none on file PID ; Ensure requried variables are clean N HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Setup Patient Asssociations S ^VPRPTJ("JPID","8765;-1")="52833885-af7c-4899-90be-b3a6630b2373" S ^VPRPTJ("JPID","-222V123222")="52833885-af7c-4899-90be-b3a6630b2373" @@ -582,5 +719,5 @@ D ASSERT($G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),225,"Incorrect err D SETGET^VPRJTX("vpr/mpid/8765;-1") D RESPOND^VPRJRSP D ASSERT(HTTPERR,400,"HTTPERR isn't set and should be") - D ASSERT($G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),225,"Incorrect error reason passed to client") + D ASSERT($G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),225,"Incorrect error reason passed to client") Q diff --git a/VPRJTPR1.m b/VPRJTPR1.m old mode 100755 new mode 100644 diff --git a/VPRJTPR2.m b/VPRJTPR2.m old mode 100755 new mode 100644 diff --git a/VPRJTPR3.m b/VPRJTPR3.m old mode 100755 new mode 100644 diff --git a/VPRJTPRN.m b/VPRJTPRN.m new file mode 100644 index 0000000..8db18c2 --- /dev/null +++ b/VPRJTPRN.m @@ -0,0 +1,688 @@ +VPRJTPRN ;V4W/DLW -- Unit tests for individual patient data wrapper code for jdsClient using cache.node + ; +STARTUP ; Run once before all tests + D BLDPT^VPRJTX + QUIT + ; +SHUTDOWN ; Run once after all tests + D CLRPT^VPRJTX + QUIT + ; +SETUP ; Run before each test + K ^||TMP + QUIT + ; +TEARDOWN ; Run after each test + K ^||TMP + K ^TMP + QUIT + ; +ASSERT(EXPECT,ACTUAL,MSG) ; convenience + D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) + QUIT + ; + ; +GETPTMISSINGPID ;; @TEST get patient demographics data with missing pid + N ERROR,PID,RESULT,UUID + S PID="" + ; + S RESULT=$$GETPT^VPRJPRN(PID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing patient identifiers",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(211,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETPTPIDNOSYNC ;; @TEST get patient demographics data from missing patient + N ERROR,PID,RESULT,UUID + ; clear patient + D SHUTDOWN + ; + S PID="93EF;-7" + ; + S RESULT=$$GETPT^VPRJPRN(PID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Identifier 93EF;-7",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("Patient Demographics not on File",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(225,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETPTBYPID ;; @TEST get patient demographic data by pid + N ERROR,PID,RESULT,UUID + ; add patient + D STARTUP + ; + S PID="93EF;-7" + ; + S RESULT=$$GETPT^VPRJPRN(PID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,0,2))) + D ASSERT(1,$D(^TMP(UUID,$J,0,3))) + D ASSERT(1,$D(^TMP(UUID,$J,0,4))) + D ASSERT(1,$D(^TMP(UUID,$J,0,5))) + D ASSERT(0,$D(^TMP(UUID,$J,0,6))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + QUIT + ; +GETPTMISSINGICN ;; @TEST get patient demographics data with missing pid + N ERROR,ICN,PID,RESULT,UUID + ; + S PID=$$ADDPT^VPRJTX("HDRDEMOG7^VPRJTP01") + ; + S ICN="" + ; + S RESULT=$$GETPT^VPRJPRN(ICN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing patient identifiers",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(211,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETPTICNNOSYNC ;; @TEST get patient demographics data from missing patient + N ERROR,ICN,RESULT,UUID + ; clear patient + D SHUTDOWN + ; + S ICN="-777V123777" + ; + S RESULT=$$GETPT^VPRJPRN(ICN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Identifier -777V123777",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain"))) + D ASSERT("JPID Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(224,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETPTBYICN ;; @TEST get patient demographic data by pid + N ERROR,ICN,PID,RESULT,UUID + ; add patient + D STARTUP + S PID=$$ADDPT^VPRJTX("HDRDEMOG7^VPRJTP01") + ; + S ICN="-777V123777" + ; + S RESULT=$$GETPT^VPRJPRN(ICN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(0,ERROR) + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,0,2))) + D ASSERT(1,$D(^TMP(UUID,$J,0,3))) + D ASSERT(1,$D(^TMP(UUID,$J,0,4))) + D ASSERT(1,$D(^TMP(UUID,$J,0,5))) + D ASSERT(0,$D(^TMP(UUID,$J,0,6))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + QUIT + ; +GETINDEXMISSINGPID ;; @TEST get patient index data with missing pid + N ERROR,INDEX,PID,RESULT,UUID + ; + S PID=$$ADDPT^VPRJTX("EHMPDOCS1^VPRJTP01") + S PID="" + S INDEX="consult" + ; + S RESULT=$$INDEX^VPRJPRN(PID,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing PID",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(226,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETINDEXMISSINGINDEX ;; @TEST get patient index data with missing index name + N ERROR,INDEX,PID,RESULT,UUID + ; + S PID="93EF;-7" + S INDEX="" + ; + S RESULT=$$INDEX^VPRJPRN(PID,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETINDEXNOSYNC ;; @TEST get patient index data from missing patient + N ERROR,INDEX,PID,RESULT,UUID + ; clear patient + D SHUTDOWN + ; + S PID="93EF;-7" + S INDEX="consult" + ; + S RESULT=$$INDEX^VPRJPRN(PID,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing patient identifiers",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(211,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETINDEX ;; @TEST get patient index data + N ERROR,INDEX,PID,RESULT,UUID + ; add patient + D STARTUP + ; + S PID=$$ADDPT^VPRJTX("EHMPDOCS1^VPRJTP01") + S INDEX="consult" + ; + S RESULT=$$INDEX^VPRJPRN(PID,INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,0,2))) + D ASSERT(0,$D(^TMP(UUID,$J,0,3))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + QUIT + ; +GETALLINDEXMISSINGINDEX ;; @TEST get all patient index data with missing index name + N ERROR,INDEX,RESULT,UUID + ; + S INDEX="" + ; + S RESULT=$$ALLINDEX^VPRJPRN(INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETALLINDEX ;; @TEST get all patient index data + N ERROR,INDEX,PID1,PID2,PID3,RESULT,UUID + ; add patient + D STARTUP + ; + S PID1=$$ADDPT^VPRJTX("DEMOG7^VPRJTP01") ; Make sure it's really there + S PID2=$$ADDPT^VPRJTX("DEMOG8^VPRJTP01") + S PID3=$$ADDPT^VPRJTX("DEMOG9^VPRJTP01") + ; + S INDEX="patient" + ; + S RESULT=$$ALLINDEX^VPRJPRN(INDEX) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID)),"expected data, none returned") + D ASSERT(3,$O(^TMP(UUID,$J,"A"),-1)+1,"incorrect number of items") ; +1 because the array is 0-indexed A skips PREAMBLE, POSTAMBLE, and STATUS + D ASSERT("""urn:va:patient:93EF:-9:-9""}",$G(^TMP(UUID,$J,2,7)),"unexpected last item") + D ASSERT("{""addresses"":[{""city"":""Any Town"",""postalCode"":""99998-0071"",""stateProvince"":""WEST VIRGINIAN""}],",$G(^TMP(UUID,$J,0,1)),"unexpected first item") + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE")),"PREAMBLE not defined") + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE")),"POSTAMBLE not defined") + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS")),"STATUS not defined") + ; + QUIT + ; +GETFINDMISSINGPID ;; @TEST get patient domain data with missing pid + N DOMAIN,ERROR,PID,RESULT,UUID + ; + S PID="" + S DOMAIN="patient" + ; + S RESULT=$$FIND^VPRJPRN(PID,DOMAIN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing PID",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(226,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETFINDMISSINGDOMAIN ;; @TEST get patient domain data with missing domain name + N DOMAIN,ERROR,PID,RESULT,UUID + ; + S PID="93EF;-7" + S DOMAIN="" + ; + S RESULT=$$FIND^VPRJPRN(PID,DOMAIN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing collection name",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(215,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETFINDNOSYNC ;; @TEST get patient domain data from missing patient + N DOMAIN,ERROR,PID,RESULT,UUID + ; clear patient + D SHUTDOWN + ; + S PID="93EF;-7" + S DOMAIN="patient" + ; + S RESULT=$$FIND^VPRJPRN(PID,DOMAIN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing patient identifiers",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(211,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETFIND ;; @TEST get patient domain data + N DOMAIN,ERROR,PID,RESULT,UUID + ; add patient + D STARTUP + ; + S PID="93EF;-7" + S DOMAIN="patient" + ; + S RESULT=$$FIND^VPRJPRN(PID,DOMAIN) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,0,2))) + D ASSERT(1,$D(^TMP(UUID,$J,0,3))) + D ASSERT(1,$D(^TMP(UUID,$J,0,4))) + D ASSERT(1,$D(^TMP(UUID,$J,0,5))) + D ASSERT(0,$D(^TMP(UUID,$J,0,6))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + QUIT + ; +GETALLFINDMISSINGDOMAIN ;; @TEST get all patient domain data with missing domain name + N DOMAIN,ERROR,FILTER,RESULT,UUID + ; + S FILTER="" + S DOMAIN="" + ; + S RESULT=$$ALLFIND^VPRJPRN(DOMAIN,,,,FILTER) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing collection name",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(215,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETALLFINDMISSINGFILTER ;; @TEST get all patient domain data with missing domain name + N DOMAIN,ERROR,FILTER,RESULT,UUID + ; + S FILTER="" + S DOMAIN="patient" + ; + S RESULT=$$ALLFIND^VPRJPRN(DOMAIN,,,,FILTER) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Filter required",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(112,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETALLFIND ;; @TEST get patient domain data + N DOMAIN,ERROR,FILTER,PID1,PID2,PID3,RESULT,UUID + ; add patient + D STARTUP + ; + S PID1=$$ADDPT^VPRJTX("DEMOG7^VPRJTP01") ; Make sure it's really there + S PID2=$$ADDPT^VPRJTX("DEMOG8^VPRJTP01") + S PID3=$$ADDPT^VPRJTX("DEMOG9^VPRJTP01") + ; + S FILTER="exists(uid)" + S DOMAIN="patient" + ; + S RESULT=$$ALLFIND^VPRJPRN(DOMAIN,,,,FILTER) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID)),"expected data, none returned") + D ASSERT(3,$O(^TMP(UUID,$J,"A"),-1)+1,"incorrect number of items") ; +1 because the array is 0-indexed A skips PREAMBLE, POSTAMBLE, and STATUS + D ASSERT("""urn:va:patient:93EF:-9:-9""}",$G(^TMP(UUID,$J,2,7)),"unexpected last item") + D ASSERT("{""addresses"":[{""city"":""Any Town"",""postalCode"":""99998-0071"",""stateProvince"":""WEST VIRGINIAN""}],",$G(^TMP(UUID,$J,0,1)),"unexpected first item") + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE")),"PREAMBLE not defined") + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE")),"POSTAMBLE not defined") + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS")),"STATUS not defined") + ; + QUIT + ; +GETCOUNTMISSINGPID ;; @TEST get patient count data with missing pid + N CNTNAME,ERROR,PID,RESULT,UUID + ; + S PID="" + S CNTNAME="collection" + ; + S RESULT=$$COUNT^VPRJPRN(PID,CNTNAME) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing PID",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(226,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETCOUNTMISSINGDOMAIN ;; @TEST get patient count data with missing count name + N CNTNAME,ERROR,PID,RESULT,UUID + ; + S PID="93EF;-7" + S CNTNAME="" + ; + S RESULT=$$COUNT^VPRJPRN(PID,CNTNAME) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETCOUNTNOSYNC ;; @TEST get patient count data from missing patient + N CNTNAME,ERROR,PID,RESULT,UUID + ; clear patient + D SHUTDOWN + ; + S PID="93EF;-7" + S CNTNAME="collection" + ; + S RESULT=$$COUNT^VPRJPRN(PID,CNTNAME) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing patient identifiers",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(211,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETCOUNT ;; @TEST get patient count data + N CNTNAME,ERROR,PID,RESULT,UUID + ; add patient + D STARTUP + ; + S PID="93EF;-7" + S CNTNAME="collection" + ; + S RESULT=$$COUNT^VPRJPRN(PID,CNTNAME) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,1))) + D ASSERT(0,$D(^TMP(UUID,$J,2))) + ; + QUIT + ; +GETALLCOUNTMISSINGCOLLECTION ;; @TEST get all count data with missing collection + N CNTNAME,ERROR,RESULT,UUID + ; + S CNTNAME="" + ; + S RESULT=$$ALLCOUNT^VPRJPRN(CNTNAME) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETALLCOUNT ;; @TEST get all count data + N CNTNAME,ERROR,PID1,PID2,PID3,RESULT,UUID + ; + ; clean up dirty global for consistent runs + K ^VPRPTX("count") + ; + ; add patient + D STARTUP + ; + S PID1=$$ADDPT^VPRJTX("DEMOG7^VPRJTP01") ; Make sure it's really there + S PID2=$$ADDPT^VPRJTX("DEMOG8^VPRJTP01") + S PID3=$$ADDPT^VPRJTX("DEMOG9^VPRJTP01") + ; + S CNTNAME="collection" + ; + S RESULT=$$ALLCOUNT^VPRJPRN(CNTNAME) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID)),"expected data to be returned") + D ASSERT(1,$G(^TMP(UUID,$J,1))["{""topic"":""patient"",""count"":2}","expected 2 patient items") + D ASSERT(200,$G(^TMP(UUID,$J,"STATUS")),"expected 200 status") + ; + QUIT + ; +GETOBJMISSINGPID ;; @TEST get patient data item with missing pid + N ERROR,PID,RESULT,UID,UUID + ; + S PID="" + S UID="urn:va:patient:93EF:-7:-7" + ; + S RESULT=$$GETOBJ^VPRJPRN(PID,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing PID",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(226,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETOBJMISSINGUID ;; @TEST get patient data item with missing uid + N ERROR,PID,RESULT,UID,UUID + ; + S PID="93EF;-7" + S UID="" + ; + S RESULT=$$GETOBJ^VPRJPRN(PID,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing UID",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(207,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETOBJNOSYNC ;; @TEST get patient data item from missing patient + N ERROR,PID,RESULT,UID,UUID + ; clear patient + D SHUTDOWN + ; + S PID="93EF;-7" + S UID="urn:va:patient:93EF:-7:-7" + ; + S RESULT=$$GETOBJ^VPRJPRN(PID,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Bad key",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(104,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETOBJECT ;; @TEST get patient data item + N ERROR,PID,RESULT,UID,UUID + ; add patient + D STARTUP + ; + S PID="93EF;-7" + S UID="urn:va:patient:93EF:-7:-7" + ; + S RESULT=$$GETOBJ^VPRJPRN(PID,UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID))) + D ASSERT(1,$D(^TMP(UUID,$J,0,1))) + D ASSERT(1,$D(^TMP(UUID,$J,0,2))) + D ASSERT(1,$D(^TMP(UUID,$J,0,3))) + D ASSERT(1,$D(^TMP(UUID,$J,0,4))) + D ASSERT(1,$D(^TMP(UUID,$J,0,5))) + D ASSERT(0,$D(^TMP(UUID,$J,0,6))) + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE"))) + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS"))) + ; + QUIT + ; +GETUIDMISSINGUID ;; @TEST get patient data item with missing uid + N ERROR,RESULT,UID,UUID + ; + S UID="" + ; + S RESULT=$$GETUID^VPRJPRN(UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Missing UID",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(207,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Bad Request",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETUIDNOSYNC ;; @TEST get patient data item from missing patient + N ERROR,RESULT,UID,UUID + ; clear patient + D SHUTDOWN + ; + S UID="urn:va:patient:93EF:-7:-7" + ; + S RESULT=$$GETUID^VPRJPRN(UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(1,ERROR) + D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J))) + D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code"))) + D ASSERT("Unable to determine patient",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message"))) + D ASSERT(203,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason"))) + D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message"))) + ; + QUIT + ; +GETUID ;; @TEST get patient data item + N ERROR,PID,RESULT,UID,UUID + ; add patient + D STARTUP + ; + S PID="93EF;-7" + S UID="urn:va:patient:93EF:-7:-7" + ; + S RESULT=$$GETUID^VPRJPRN(UID) + S ERROR=$P(RESULT,":") + S UUID=$P(RESULT,":",2) + ; + D ASSERT(10,$D(^TMP(UUID)),"expected data, none returned") + D ASSERT(5,$O(^TMP(UUID,$J,0,"A"),-1),"incorrect number of items") + D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE")),"PREAMBLE not defined") + D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE")),"POSTAMBLE not defined") + D ASSERT(1,$D(^TMP(UUID,$J,"STATUS")),"STATUS not defined") + D ASSERT(0,$D(^TMP("HTTPERR",UUID,$J))) + ; + QUIT + ; diff --git a/VPRJTPS.m b/VPRJTPS.m old mode 100755 new mode 100644 index 3c16e95..08fe090 --- a/VPRJTPS.m +++ b/VPRJTPS.m @@ -35,11 +35,11 @@ D ASSERT("",$G(VPRJTPID)) D ASSERT(0,$D(^VPRPT("52833885-af7c-4899-90be-b3a6630b2369",VPRJTPID,"urn:va:patient:93EF:-7:-7"))) D ASSERT("",$G(^VPRPTJ("JPID",VPRJTPID))) D ASSERT(0,$D(^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369"))) - D ASSERT(10,$D(^TMP("HTTPERR",$J)),"An HTTP Error did not occur while filing data") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"A 404 error code should have occurred") - D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error should have occurred") - K ^TMP("HTTPERR") - K ^TMP("VPRJERR") + D ASSERT(10,$D(^||TMP("HTTPERR",$J)),"An HTTP Error did not occur while filing data") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"A 404 error code should have occurred") + D ASSERT(224,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error should have occurred") + K ^||TMP("HTTPERR") + K ^||TMP("VPRJERR") Q ADDOBJUNKJPID ;; @TEST Error condition when JPID is unknown adding an object N DATA,LOC,METASTAMP,VPRJTPID,HTTPERR,VPRJPID @@ -55,10 +55,10 @@ D ASSERT(0,$D(^VPRPT)) D ASSERT(0,$D(^VPRPTJ("JSON"))) D ASSERT(0,$D(^VPRPTJ("TEMPLATE"))) D ASSERT("",$G(^VPRPTI)) - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"A 404 error code should have occurred") - D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error should have occurred") - K ^TMP("HTTPERR") - K ^TMP("VPRJERR") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"A 404 error code should have occurred") + D ASSERT(224,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error should have occurred") + K ^||TMP("HTTPERR") + K ^||TMP("VPRJERR") Q ADDPT ;; @TEST adding a patient N DATA,METASTAMP,VPRJTPID,HTTPERR,PTIME,TIME,VPRJPID @@ -125,7 +125,7 @@ D ASSERT(1,$D(^VPRPTI(VPRJPID,VPRJTPID,"attr","med-active-outpt","79939681=","ur S VPRJPID=$$JPID4PID^VPRJPR(VPRJTPID) F I=1:1:5 S TAGS(I)="DATA"_I_"^VPRJTP03" D ADDDATA^VPRJTX(.TAGS,VPRJTPID) - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error occured filing data") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error occured filing data") D ASSERT(1,$D(^VPRPTI(VPRJPID,VPRJTPID,"rev","urn:va:utesta:93EF:-7:1","utest-multiple","urn:va:utestc:93EF:-7:23","items#1"))) D ASSERT(1,$D(^VPRPTI(VPRJPID,VPRJTPID,"rev","urn:va:utestb:93EF:-7:3","utest-multiple","urn:va:utestc:93EF:-7:23","items#2"))) D ASSERT(1,$D(^VPRPTI(VPRJPID,VPRJTPID,"rev","urn:va:utesta:93EF:-7:2","utest-single","urn:va:utestc:93EF:-7:23",1))) @@ -237,36 +237,38 @@ D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") I $G(VPRJPID)="" QUIT F I=6:1:7 S TAGS(I)="SRV"_I_"^VPRJTP03" D ADDDATA^VPRJTX(.TAGS,VPRJTPID) - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error occured filing data") - D ASSERT(10,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:utesta:9999:-7:6"))) + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error occured filing data") + D ASSERT(10,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:utesta:PORT:-7:6"))) D ASSERT(10,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:utesta:93EF:-7:7"))) - D DELCLTN^VPRJPS(VPRJTPID,"utesta","9999") + D DELCLTN^VPRJPS(VPRJTPID,"utesta","PORT") S PTIME=TIME H 1 S TIME=$G(^VPRMETA("JPID",VPRJPID,"lastAccessTime")) D ASSERT(1,TIME>PTIME) - D ASSERT(0,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:utesta:9999:-7:6"))) + D ASSERT(0,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:utesta:PORT:-7:6"))) D ASSERT(10,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:utesta:93EF:-7:7"))) Q + ; DELPT ;; @TEST deleting a patient and all places data exists - N JPID,TYPE,TYPE2,STAMP,VPRJTPID,HTTPERR + N PID,JPID,TYPE,TYPE2,STAMP,VPRJTPID,HTTPERR S VPRJTPID="93EF;-7" ; Add job status K ^VPRJOB K ^VPRPTJ("JPID") D PATIDS S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S PID="93EF;-7" S TYPE="jmeadows-lab-sync-request" S TYPE2="jmeadows-vitals-sync-request" S STAMP=201412180711200 - D JOBSTATG^VPRJTJOB(2,1,JPID,TYPE,STAMP,"created") - D JOBSTATG^VPRJTJOB(3,1,JPID,TYPE2,STAMP+1,"created") + D JOBSTATG^VPRJTJOB(2,1,"pid",PID,TYPE,STAMP,"created") + D JOBSTATG^VPRJTJOB(3,1,"pid",PID,TYPE2,STAMP+1,"created") D ASSERT(10,$D(^VPRJOB(1)),"Job status Sequential Counter 1 does not exist and should") D ASSERT(10,$D(^VPRJOB(2)),"Job status Sequential Counter 2 does not exist and should") ; Add sync status N RETURN,BODY,ARG K ^VPRSTATUS(JPID,VPRJTPID) - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT^VPRJTSYSS(.BODY,"93EF;-7","-777V123777") S ARG("id")="93EF;-7" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) @@ -329,32 +331,61 @@ D ASSERT(0,$D(^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","-777V123777 ; Ensure job status is deleted D ASSERT(0,$D(^VPRJOB(1)),"Job status Sequential Counter 1 does exist and should not") D ASSERT(0,$D(^VPRJOB(2)),"Job status Sequential Counter 2 does exist and should not") + ; Ensure lastAccessTime is deleted + D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"A lastAccessTime data node exists and should not") Q + ; DELSITE ;; @TEST Delete a site's patient data - N VPRJTPID1,VPRJTPID2,TAGS,I + N VPRJTPID1,VPRJTPID2,VPRJPID1,VPRJPID2,TAGS,I S VPRJTPID1="93EF;-7" S VPRJTPID2="93EF;-8" S VPRJTPID1=$$ADDPT^VPRJTX("DEMOG7^VPRJTP01") F I=1:1:3 S TAGS(I)="UTST"_I_"^VPRJTP01" D ADDDATA^VPRJTX(.TAGS,VPRJTPID1) S VPRJTPID2=$$ADDPT^VPRJTX("DEMOG8^VPRJTP01") + S VPRJPID1=$$JPID4PID^VPRJPR(VPRJTPID1) + S VPRJPID2=$$JPID4PID^VPRJPR(VPRJTPID2) F I=4:1:5 S TAGS(I)="UTST"_I_"^VPRJTP01" D ADDDATA^VPRJTX(.TAGS,VPRJTPID2) - D ASSERT(10,$D(^VPRPT($$JPID4PID^VPRJPR(VPRJTPID1),VPRJTPID1))) - D ASSERT(10,$D(^VPRPTJ("JSON",$$JPID4PID^VPRJPR(VPRJTPID1),VPRJTPID1))) - D ASSERT(10,$D(^VPRPTJ("TEMPLATE",$$JPID4PID^VPRJPR(VPRJTPID1),VPRJTPID1))) - D ASSERT(1,^VPRPTI($$JPID4PID^VPRJPR(VPRJTPID1),VPRJTPID1,"tally","collection","patient")) - D ASSERT(10,$D(^VPRPT($$JPID4PID^VPRJPR(VPRJTPID2),VPRJTPID2))) - D ASSERT(10,$D(^VPRPTJ("JSON",$$JPID4PID^VPRJPR(VPRJTPID2),VPRJTPID2))) - D ASSERT(10,$D(^VPRPTJ("TEMPLATE",$$JPID4PID^VPRJPR(VPRJTPID2),VPRJTPID2))) - D ASSERT(1,^VPRPTI($$JPID4PID^VPRJPR(VPRJTPID2),VPRJTPID2,"tally","collection","patient")) + D ASSERT(10,$D(^VPRPT(VPRJPID1,VPRJTPID1))) + D ASSERT(10,$D(^VPRPTJ("JSON",VPRJPID1,VPRJTPID1))) + D ASSERT(10,$D(^VPRPTJ("TEMPLATE",VPRJPID1,VPRJTPID1))) + D ASSERT(1,^VPRPTI(VPRJPID1,VPRJTPID1,"tally","collection","patient")) + D ASSERT(1,$D(^VPRMETA("JPID",VPRJPID1,"lastAccessTime")),"A lastAccessTime data node does not exist and should") + D ASSERT(10,$D(^VPRPT(VPRJPID2,VPRJTPID2))) + D ASSERT(10,$D(^VPRPTJ("JSON",VPRJPID2,VPRJTPID2))) + D ASSERT(10,$D(^VPRPTJ("TEMPLATE",VPRJPID2,VPRJTPID2))) + D ASSERT(1,^VPRPTI(VPRJPID2,VPRJTPID2,"tally","collection","patient")) + D ASSERT(1,$D(^VPRMETA("JPID",VPRJPID2,"lastAccessTime")),"A lastAccessTime data node does not exist and should") D DELSITE^VPRJPS("93EF") D ASSERT(0,$D(^VPRPT("52833885-af7c-4899-90be-b3a6630b2369",VPRJTPID1))) D ASSERT(0,$D(^VPRPTJ("JSON","52833885-af7c-4899-90be-b3a6630b2369",VPRJTPID1))) D ASSERT(0,$D(^VPRPTJ("TEMPLATE","52833885-af7c-4899-90be-b3a6630b2369",VPRJTPID1))) D ASSERT(0,^VPRPTI("52833885-af7c-4899-90be-b3a6630b2369",VPRJTPID1,"tally","collection","patient")) + ; VPRJPID1 has HDR data, while VPRJPID2 does not. lastAccessTime will still be here because of the HDR data + D ASSERT(1,$D(^VPRMETA("JPID",VPRJPID1,"lastAccessTime")),"A lastAccessTime data node does not exist and it should") D ASSERT(0,$D(^VPRPT("52833885-af7c-4899-90be-b3a6630b2370",VPRJTPID2))) D ASSERT(0,$D(^VPRPTJ("JSON","52833885-af7c-4899-90be-b3a6630b2370",VPRJTPID2))) D ASSERT(0,$D(^VPRPTJ("TEMPLATE","52833885-af7c-4899-90be-b3a6630b2370",VPRJTPID2))) D ASSERT(0,^VPRPTI("52833885-af7c-4899-90be-b3a6630b2370",VPRJTPID2,"tally","collection","patient")) + D ASSERT(0,$D(^VPRMETA("JPID",VPRJPID2,"lastAccessTime")),"A lastAccessTime data node exists and should not") + QUIT + ; +RESENDERRDEVENT ;; @TEST resending an event that had a syncError + N DATA,LOC,METASTAMP,VPRJTPID,HTTPERR,PTIME,TIME,VPRJPID,NEWMETASTAMP + ; First, manually setup an entry to look like a syncError + D PATIDS + S VPRJTPID="93EF;-7" + S VPRJPID=$$JPID4PID^VPRJPR(VPRJTPID) + S METASTAMP=71 + S ^VPRSTATUS(VPRJPID,VPRJTPID,"93EF","med","urn:va:med:93EF:-7:16982",METASTAMP,"syncError")=1 + K ^VPRSTATUS(VPRJPID,VPRJTPID,"93EF","med","urn:va:med:93EF:-7:16982",METASTAMP,"stored") + ; Now resend the event + D GETDATA^VPRJTX("MED1","VPRJTP02",.DATA) + S LOC=$$SAVE^VPRJPS(VPRJPID,.DATA) + S NEWMETASTAMP=$O(^VPRPT(VPRJPID,VPRJTPID,"urn:va:med:93EF:-7:16982",""),-1) + D ASSERT(METASTAMP,NEWMETASTAMP,"Resending event created new metastamp") + D ASSERT(10,$D(^VPRPT(VPRJPID,VPRJTPID,"urn:va:med:93EF:-7:16982",NEWMETASTAMP)),"Resending event didn't create entry") + D ASSERT("",$G(^VPRSTATUS(VPRJPID,VPRJTPID,"93EF","med","urn:va:med:93EF:-7:16982",NEWMETASTAMP,"syncError")),"Sync Error should have been cleared") + D ASSERT(1,$G(^VPRSTATUS(VPRJPID,VPRJTPID,"93EF","med","urn:va:med:93EF:-7:16982",NEWMETASTAMP,"stored")),"Object should be stored") Q diff --git a/VPRJTPSTATUS.m b/VPRJTPSTATUS.m index 19f2375..41a3db9 100644 --- a/VPRJTPSTATUS.m +++ b/VPRJTPSTATUS.m @@ -1,4 +1,4 @@ -VPRJTPSTATUS ;KRM/CJE -- Unit Tests for business logic based sync status endpoints +VPRJTPSTATUS ;KRM/CJE,V4W/DLW -- Unit Tests for business logic based sync status endpoints ; STARTUP ; Run once before all tests K ^VPRSTATUS @@ -19,7 +19,9 @@ Q TEARDOWN ; Run after each test K HTTPREQ,HTTPERR,HTTPRSP - K ^VPRJOB + K ^VPRJOB,^VPRSTATUS + K ^||TMP("HTTPERR",$J) + K ^||TMP($J) Q ASSERT(EXPECT,ACTUAL,MSG) ; for convenience D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) @@ -44,16 +46,40 @@ S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1002",STAMPTIME,"stored")=1 Q ; +COMPLETEBASICSOLR(SITE,ID,STAMPTIME) + I $G(STAMPTIME)="" S STAMPTIME=20141031094920 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"vitals","urn:va:vitals:"_SITE_":"_ID_":1001",STAMPTIME,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"vitals","urn:va:vitals:"_SITE_":"_ID_":1002",STAMPTIME,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1001",STAMPTIME,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1002",STAMPTIME,"solrStored")=1 + Q + ; +COMPLETEBASICSYNCERR(SITE,ID,STAMPTIME) + I $G(STAMPTIME)="" S STAMPTIME=20141031094920 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"vitals","urn:va:vitals:"_SITE_":"_ID_":1001",STAMPTIME,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"vitals","urn:va:vitals:"_SITE_":"_ID_":1002",STAMPTIME,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1001",STAMPTIME,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1002",STAMPTIME,"syncError")=1 + Q + ; +COMPLETEBASICSOLRERR(SITE,ID,STAMPTIME) + I $G(STAMPTIME)="" S STAMPTIME=20141031094920 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"vitals","urn:va:vitals:"_SITE_":"_ID_":1001",STAMPTIME,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"vitals","urn:va:vitals:"_SITE_":"_ID_":1002",STAMPTIME,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1001",STAMPTIME,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369",SITE_";"_ID,SITE,"allergy","urn:va:allergy:"_SITE_":"_ID_":1002",STAMPTIME,"solrError")=1 + Q + ; PATIDS ; Setup patient identifiers S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","9E7A;3")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","C877;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","1234V4321")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","DOD;12345678")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","HDR;1234V4321")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","VLER;1234V4321")="" - S ^VPRPTJ("JPID","9E7A;3")="52833885-af7c-4899-90be-b3a6630b2369" - S ^VPRPTJ("JPID","C877;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" S ^VPRPTJ("JPID","1234V4321")="52833885-af7c-4899-90be-b3a6630b2369" S ^VPRPTJ("JPID","DOD;12345678")="52833885-af7c-4899-90be-b3a6630b2369" S ^VPRPTJ("JPID","HDR;1234V4321")="52833885-af7c-4899-90be-b3a6630b2369" @@ -62,8 +88,8 @@ ; DELPATIDS ; Delete patient identifiers K ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369") - K ^VPRPTJ("JPID","9E7A;3") - K ^VPRPTJ("JPID","C877;3") + K ^VPRPTJ("JPID","SITE;3") + K ^VPRPTJ("JPID","SITE;3") K ^VPRPTJ("JPID","1234V4321") K ^VPRPTJ("JPID","DOD;12345678") K ^VPRPTJ("JPID","HDR;1234V4321") @@ -88,7 +114,7 @@ S JOB("type")=TYPE ; GETBEFORE ;; @TEST Get Patient Sync Status before metastamp stored N DATA,ARG,ERR,OBJECT,HTTPERR - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -99,7 +125,7 @@ D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") ; ; Try again with an event stored, but no meta-stamp is stored - S ^VPRSTATUS("9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -112,7 +138,7 @@ D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") Q ; GETSTARTEDESR ;; @TEST Get Patient Sync Status ICN - ESR started, no meta-stamp or other jobs - N DATA,ARG,ERR,OBJECT,HTTPERR + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID ; ; Modify patient identifiers D DELPATIDS @@ -146,8 +172,8 @@ D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") ; GETSINGLEINPROGRESS ;; @TEST Get Single Site in-progress Patient Sync Status - no jobs N DATA,ARG,ERR,OBJECT,HTTPERR - D BASIC("9E7A",3) - S ARG("icnpidjpid")="9E7A;3" + D BASIC("SITE",3) + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -156,16 +182,16 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLECOMPLETE ;; @TEST Get Single Site complete Patient Sync Status - no jobs N DATA,ARG,ERR,OBJECT,HTTPERR - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -174,20 +200,20 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") I $D(DATA) K @DATA Q GETSINGLEESRERR ;; @TEST Get Single Site complete Patient Sync Status - enterprise-sync-request in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"error",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"error",20160420110400,"enterprise-sync-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -199,16 +225,16 @@ D ASSERT("true",$G(OBJECT("hasError")),"hasError attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") I $D(DATA) K @DATA Q -GETSINGLEVSR ;; @TEST Get Single Site complete Patient Sync Status - vista-9E7A-subscribe-request created +GETSINGLEVSR ;; @TEST Get Single Site complete Patient Sync Status - vista-SITE-subscribe-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"created",20160420110400,"vista-9E7A-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"vista-SITE-subscribe-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -217,20 +243,20 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") I $D(DATA) K @DATA Q -GETSINGLEVDP ;; @TEST Get Single Site complete Patient Sync Status - vista-9E7A-data-allergy-poller created +GETSINGLEVDP ;; @TEST Get Single Site complete Patient Sync Status - vista-SITE-data-allergy-poller created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"created",20160420110400,"vista-9E7A-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"vista-SITE-data-allergy-poller") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -239,20 +265,20 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") I $D(DATA) K @DATA Q -GETSINGLEVHSR ;; @TEST Get Single Site complete Patient Sync Status - vistahdr-C877-subscribe-request created +GETSINGLEVHSR ;; @TEST Get Single Site complete Patient Sync Status - vistahdr-SITE-subscribe-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("C877;3",ROOTJOBID,"created",20160420110400,"vistahdr-C877-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"vistahdr-SITE-subscribe-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -261,22 +287,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid should exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") I $D(DATA) K @DATA Q -GETSINGLEVHDP ;; @TEST Get Single Site complete Patient Sync Status - vistahdr-C877-data-allergy-poller created +GETSINGLEVHDP ;; @TEST Get Single Site complete Patient Sync Status - vistahdr-SITE-data-allergy-poller created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("C877;3",ROOTJOBID,"created",20160420110400,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"vistahdr-SITE-data-allergy-poller") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -285,22 +311,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEHSR ;; @TEST Get Single Site complete Patient Sync Status - hdr-subscribe-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("HDR;1234V4321",ROOTJOBID,"created",20160420110400,"hdr-subscribe-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -309,22 +335,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEHS ;; @TEST Get Single Site complete Patient Sync Status - hdr-sync-allergy-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("HDR;1234V4321",ROOTJOBID,"created",20160420110400,"hdr-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -333,22 +359,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEHX ;; @TEST Get Single Site complete Patient Sync Status - hdr-xform-allergy-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("HDR;1234V4321",ROOTJOBID,"created",20160420110400,"hdr-xform-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -357,22 +383,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEJS ;; @TEST Get Single Site complete Patient Sync Status - jmeadows-sync-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("DOD;12345678",ROOTJOBID,"created",20160420110400,"jmeadows-sync-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -381,22 +407,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEJDR ;; @TEST Get Single Site complete Patient Sync Status - jmeadows-document-retrieval created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("DOD;12345678",ROOTJOBID,"created",20160420110400,"jmeadows-document-retrieval") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -405,22 +431,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEJPDT ;; @TEST Get Single Site complete Patient Sync Status - jmeadows-pdf-document-transform created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("DOD;12345678",ROOTJOBID,"created",20160420110400,"jmeadows-pdf-document-transform") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -429,22 +455,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEJX ;; @TEST Get Single Site complete Patient Sync Status - jmeadows-xform-allergy-vpr created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT D JOB("DOD;12345678",ROOTJOBID,"created",20160420110400,"jmeadows-xform-allergy-vpr") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -453,22 +479,22 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") I $D(DATA) K @DATA Q GETSINGLEJCDC ;; @TEST Get Single Site complete Patient Sync Status - jmeadows-cda-document-conversion created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT D JOB("DOD;12345678",ROOTJOBID,"created",20160420110400,"jmeadows-cda-document-conversion") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -477,18 +503,18 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") I $D(DATA) K @DATA Q GETALLESR ;; @TEST Get ALL site complete Patient Sync Status - enterprise-sync-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) - D BASIC("C877",3) - D COMPLETEBASIC("C877",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) D BASIC("HDR","1234V4321") D COMPLETEBASIC("HDR","1234V4321") D BASIC("DOD",12345678) @@ -496,9 +522,9 @@ D COMPLETEBASIC("DOD",12345678) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -507,10 +533,10 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") @@ -519,10 +545,10 @@ D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD should Q GETALLESRVHSR ;; @TEST Get ALL site complete Patient Sync Status - enterprise-sync-request,vistahdr-sync-request created N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) - D BASIC("C877",3) - D COMPLETEBASIC("C877",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) D BASIC("HDR","1234V4321") D COMPLETEBASIC("HDR","1234V4321") D BASIC("DOD",12345678) @@ -530,10 +556,10 @@ D COMPLETEBASIC("DOD",12345678) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - ;D JOB("9E7A;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") - ;D JOB("C877;3",ROOTJOBID,"complete",20160420110400,"vistahdr-C877-subscribe-request") + ;D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") + ;D JOB("SITE;3",ROOTJOBID,"complete",20160420110400,"vistahdr-SITE-subscribe-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -542,10 +568,10 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") @@ -554,13 +580,13 @@ D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD should Q GETSITESINPROGRESS ;; @TEST Get single site inProgress Patient Sync Status - site filter N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D BASIC("C877",3) + D BASIC("SITE",3) + D BASIC("SITE",3) D BASIC("HDR","1234V4321") D BASIC("DOD",12345678) ; - S ARG("icnpidjpid")="9E7A;3" - S ARG("sites")="9E7A" + S ARG("icnpidjpid")="SITE;3" + S ARG("sites")="SITE" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -569,11 +595,11 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("",$G(OBJECT("syncCompleted")),"SyncCompleted shouldn't exist") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") ; No other sites should show up - D ASSERT("",$G(OBJECT("sites","C877","pid")),"Site-pid C877 shouldn't exist") - D ASSERT("",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE shouldn't exist") + D ASSERT("",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR shouldn't exist") D ASSERT("",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") D ASSERT("",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD shouldn't exist") @@ -582,17 +608,17 @@ D ASSERT("",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't b Q GETSITESCOMPLETE ;; @TEST Get single site complete Patient Sync Status - site filter N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) - D BASIC("C877",3) - D COMPLETEBASIC("C877",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) D BASIC("HDR","1234V4321") D COMPLETEBASIC("HDR","1234V4321") D BASIC("DOD",12345678) D COMPLETEBASIC("DOD",12345678) ; - S ARG("icnpidjpid")="9E7A;3" - S ARG("sites")="9E7A" + S ARG("icnpidjpid")="SITE;3" + S ARG("sites")="SITE" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -601,11 +627,11 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("",$G(OBJECT("syncCompleted")),"SyncCompleted shouldn't exist") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") ; No other sites should show up - D ASSERT("",$G(OBJECT("sites","C877","pid")),"Site-pid C877 shouldn't exist") - D ASSERT("",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE shouldn't exist") + D ASSERT("",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR shouldn't exist") D ASSERT("",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") D ASSERT("",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD shouldn't exist") @@ -614,10 +640,10 @@ D ASSERT("",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't b Q GETSITESOPENJOB ;; @TEST Get single site complete Patient Sync Status - enterprise-sync-request N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) - D BASIC("C877",3) - D COMPLETEBASIC("C877",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) D BASIC("HDR","1234V4321") D COMPLETEBASIC("HDR","1234V4321") D BASIC("DOD",12345678) @@ -625,10 +651,10 @@ D COMPLETEBASIC("DOD",12345678) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") ; - S ARG("icnpidjpid")="9E7A;3" - S ARG("sites")="9E7A" + S ARG("icnpidjpid")="SITE;3" + S ARG("sites")="SITE" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -637,11 +663,11 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("",$G(OBJECT("syncCompleted")),"SyncCompleted shouldn't exist") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") ; No other sites should show up - D ASSERT("",$G(OBJECT("sites","C877","pid")),"Site-pid C877 shouldn't exist") - D ASSERT("",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE shouldn't exist") + D ASSERT("",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR shouldn't exist") D ASSERT("",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") D ASSERT("",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD shouldn't exist") @@ -650,13 +676,13 @@ D ASSERT("",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't b Q GETMSITESINPROGRESS ;; @TEST Get multiple site inProgress Patient Sync Status - site filter N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D BASIC("C877",3) + D BASIC("SITE",3) + D BASIC("SITE",3) D BASIC("HDR","1234V4321") D BASIC("DOD",12345678) ; - S ARG("icnpidjpid")="9E7A;3" - S ARG("sites")="9E7A,DOD" + S ARG("icnpidjpid")="SITE;3" + S ARG("sites")="SITE,DOD" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -665,23 +691,23 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("",$G(OBJECT("syncCompleted")),"SyncCompleted shouldn't exist") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("DOD;12345678",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD should exist") D ASSERT("false",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") ; No other sites should show up - D ASSERT("",$G(OBJECT("sites","C877","pid")),"Site-pid C877 shouldn't exist") - D ASSERT("",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE shouldn't exist") + D ASSERT("",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR shouldn't exist") D ASSERT("",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") I $D(DATA) K @DATA Q GETMSITESCOMPLETE ;; @TEST Get multiple site complete Patient Sync Status - site filter N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) - D BASIC("C877",3) - D COMPLETEBASIC("C877",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) D BASIC("HDR","1234V4321") D COMPLETEBASIC("HDR","1234V4321") D BASIC("DOD",12345678) @@ -689,11 +715,11 @@ D COMPLETEBASIC("DOD",12345678) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110400,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110400,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110400,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110400,"hdr-sync-allergy-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110400,"hdr-xform-allergy-vpr") @@ -703,8 +729,8 @@ D COMPLETEBASIC("DOD",12345678) D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110400,"jmeadows-pdf-document-transform") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110400,"jmeadows-xform-allergy-vpr") ; - S ARG("icnpidjpid")="9E7A;3" - S ARG("sites")="9E7A,HDR" + S ARG("icnpidjpid")="SITE;3" + S ARG("sites")="SITE,HDR" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -713,23 +739,23 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("",$G(OBJECT("syncCompleted")),"SyncCompleted shouldn't exist") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR shouldn't exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") ; No other sites should show up - D ASSERT("",$G(OBJECT("sites","C877","pid")),"Site-pid C877 shouldn't exist") - D ASSERT("",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE shouldn't exist") + D ASSERT("",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") D ASSERT("",$G(OBJECT("sites","DOD","pid")),"Site-pid DOD shouldn't exist") D ASSERT("",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't be complete") I $D(DATA) K @DATA Q GETMSITESOPENJOB ;; @TEST Get multiple site complete Patient Sync Status - enterprise-sync-request N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3) - D COMPLETEBASIC("9E7A",3) - D BASIC("C877",3) - D COMPLETEBASIC("C877",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) D BASIC("HDR","1234V4321") D COMPLETEBASIC("HDR","1234V4321") D BASIC("DOD",12345678) @@ -737,10 +763,10 @@ D COMPLETEBASIC("DOD",12345678) ; ; Create enterprise-sync-request error job S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"created",20160420110400,"enterprise-sync-request") ; - S ARG("icnpidjpid")="9E7A;3" - S ARG("sites")="9E7A,C877" + S ARG("icnpidjpid")="SITE;3" + S ARG("sites")="SITE,SITE" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -749,10 +775,10 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Ensure that the JSON matches what we expect D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") D ASSERT("",$G(OBJECT("syncCompleted")),"SyncCompleted shouldn't exist") - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A shouldn't be complete") - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 shouldn't exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE shouldn't exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE shouldn't be complete") ; No other sites should show up D ASSERT("",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR shouldn't exist") D ASSERT("",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR shouldn't be complete") @@ -762,10 +788,10 @@ D ASSERT("",$G(OBJECT("sites","DOD","syncCompleted")),"Site-Sync DOD shouldn't b Q GETMSITESCOMPLETENHX ;; @TEST Get multiple site complete Patient Sync Status - REAL - NO hdr-xform, NO vler-xform, NO jmeadows-pdf, NO jmeadows-ccda, NO jmeadows-xform, NO jmeadows-document N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -775,18 +801,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -800,11 +826,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -812,11 +838,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -833,10 +859,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE1E ;; @TEST Get multiple site complete Patient Sync Status - REAL 1st job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -846,18 +872,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"error",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"error",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -871,11 +897,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should not be complete") - D ASSERT("true",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -883,11 +909,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -904,10 +930,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE2E ;; @TEST Get multiple site complete Patient Sync Status - REAL 2nd job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -917,18 +943,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"error",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"error",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -942,11 +968,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("false",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should not be complete") - D ASSERT("true",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -954,11 +980,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -975,10 +1001,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE3E ;; @TEST Get multiple site complete Patient Sync Status - REAL 3rd job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -988,18 +1014,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"error",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"error",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1013,11 +1039,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -1025,11 +1051,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should not be complete") - D ASSERT("true",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -1046,10 +1072,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE4E ;; @TEST Get multiple site complete Patient Sync Status - REAL 4th job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -1059,18 +1085,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"error",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"error",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1084,11 +1110,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -1096,11 +1122,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("false",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should not be complete") - D ASSERT("true",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -1117,10 +1143,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE5E ;; @TEST Get multiple site complete Patient Sync Status - REAL 5th job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -1130,18 +1156,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"error",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1155,11 +1181,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should not be complete") @@ -1167,11 +1193,11 @@ D ASSERT("true",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -1188,10 +1214,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE6E ;; @TEST Get multiple site complete Patient Sync Status - REAL 6th job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -1201,18 +1227,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"error",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1226,11 +1252,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("false",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should not be complete") @@ -1238,11 +1264,11 @@ D ASSERT("true",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -1259,10 +1285,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE7E ;; @TEST Get multiple site complete Patient Sync Status - REAL 7th job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -1272,18 +1298,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"error",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1297,11 +1323,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -1309,11 +1335,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("false",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should not be complete") @@ -1330,10 +1356,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE8E ;; @TEST Get multiple site complete Patient Sync Status - REAL 8th job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -1343,18 +1369,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"error",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1368,11 +1394,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should be complete") @@ -1380,11 +1406,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should not e D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should not exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -1401,10 +1427,10 @@ D ASSERT(20160420110500,$G(OBJECT("sites","DOD","latestJobTimestamp")),"Site-lat Q GETMSITESCOMPLETE9E ;; @TEST Get multiple site complete Patient Sync Status - REAL 9th job in error N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID - D BASIC("9E7A",3,20141031094920) - D COMPLETEBASIC("9E7A",3,20141031094920) - D BASIC("C877",3,20141031095020) - D COMPLETEBASIC("C877",3,20141031095020) + D BASIC("SITE",3,20141031094920) + D COMPLETEBASIC("SITE",3,20141031094920) + D BASIC("SITE",3,20141031095020) + D COMPLETEBASIC("SITE",3,20141031095020) D BASIC("HDR","1234V4321",20151031094920) D COMPLETEBASIC("HDR","1234V4321",20151031094920) D BASIC("VLER","1234V4321",20131031094920) @@ -1414,18 +1440,18 @@ D COMPLETEBASIC("DOD",12345678,20161031094920) ; ; Create jobs S ROOTJOBID=$$UUID^VPRJRUT - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110500,"vista-9E7A-subscribe-request") - D JOB("9E7A;3",ROOTJOBID,"completed",20160420110405,"vista-9E7A-data-allergy-poller") - D JOB("C877;3",ROOTJOBID,"completed",20160420110700,"vistahdr-C877-subscribe-request") - D JOB("C877;3",ROOTJOBID,"completed",20160420110800,"vistahdr-C877-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110500,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110405,"vista-SITE-data-allergy-poller") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110700,"vistahdr-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110800,"vistahdr-SITE-data-allergy-poller") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420110900,"hdr-sync-request") D JOB("HDR;1234V4321",ROOTJOBID,"completed",20160420111000,"hdr-sync-allergy-request") D JOB("VLER;1234V4321",ROOTJOBID,"completed",20160420110400,"vler-sync-request") D JOB("DOD;12345678",ROOTJOBID,"completed",20160420110430,"jmeadows-sync-request") D JOB("DOD;12345678",ROOTJOBID,"error",20160420110500,"jmeadows-sync-allergy-request") ; - S ARG("icnpidjpid")="9E7A;3" + S ARG("icnpidjpid")="SITE;3" D COMBINED^VPRJPSTATUS(.DATA,.ARG) I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -1439,11 +1465,11 @@ D ASSERT(20160420111000,$G(OBJECT("latestJobTimestamp")),"latestJobTimestamp sho D ASSERT(20161031094920,$G(OBJECT("latestSourceStampTime")),"latestSourceStampTime should exist") D ASSERT(20160420110400,$G(OBJECT("latestEnterpriseSyncRequestTimestamp")),"latestEnterpriseSyncRequestTimestamp should exist") ; - D ASSERT("9E7A;3",$G(OBJECT("sites","9E7A","pid")),"Site-pid 9E7A should exist") - D ASSERT("true",$G(OBJECT("sites","9E7A","syncCompleted")),"Site-Sync 9E7A should be complete") - D ASSERT("",$G(OBJECT("sites","9E7A","hasError")),"Site-hasError 9E7A should not exist") - D ASSERT(20141031094920,$G(OBJECT("sites","9E7A","sourceStampTime")),"Site-sourceStampTime 9E7A should exist") - D ASSERT(20160420110500,$G(OBJECT("sites","9E7A","latestJobTimestamp")),"Site-latestJobTimestamp 9E7A should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should not exist") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110500,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("HDR;1234V4321",$G(OBJECT("sites","HDR","pid")),"Site-pid HDR should exist") D ASSERT("true",$G(OBJECT("sites","HDR","syncCompleted")),"Site-Sync HDR should not be complete") @@ -1451,11 +1477,11 @@ D ASSERT("",$G(OBJECT("sites","HDR","hasError")),"Site-hasError HDR should exist D ASSERT(20151031094920,$G(OBJECT("sites","HDR","sourceStampTime")),"Site-sourceStampTime HDR should exist") D ASSERT(20160420111000,$G(OBJECT("sites","HDR","latestJobTimestamp")),"Site-latestJobTimestamp HDR should exist") ; - D ASSERT("C877;3",$G(OBJECT("sites","C877","pid")),"Site-pid C877 should exist") - D ASSERT("true",$G(OBJECT("sites","C877","syncCompleted")),"Site-Sync C877 should not be complete") - D ASSERT("",$G(OBJECT("sites","C877","hasError")),"Site-hasError C877 should exist") - D ASSERT(20141031095020,$G(OBJECT("sites","C877","sourceStampTime")),"Site-sourceStampTime C877 should exist") - D ASSERT(20160420110800,$G(OBJECT("sites","C877","latestJobTimestamp")),"Site-latestJobTimestamp C877 should exist") + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-Sync SITE should not be complete") + D ASSERT("",$G(OBJECT("sites","SITE","hasError")),"Site-hasError SITE should exist") + D ASSERT(20141031095020,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime SITE should exist") + D ASSERT(20160420110800,$G(OBJECT("sites","SITE","latestJobTimestamp")),"Site-latestJobTimestamp SITE should exist") ; D ASSERT("VLER;1234V4321",$G(OBJECT("sites","VLER","pid")),"Site-pid VLER should exist") D ASSERT("true",$G(OBJECT("sites","VLER","syncCompleted")),"Site-Sync VLER should be complete") @@ -1500,3 +1526,1464 @@ D ASSERT("true",$G(OBJECT("sites","""6242","syncCompleted")),"Site-Sync 6242 sho K ^VPRPTJ("JPID") D PATIDS Q + ; + ; SOLR stored tests + ; +GETSOLRBEFORE ;; @TEST Get Patient Simple Sync Status before metastamp stored with SOLR status + N DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("icnpidjpid")="SITE;3" + ; save off SOLR configuration + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + ; + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"SOLR Sync shouldn't be complete") + ; + ; Try again with an event stored, but no meta-stamp is stored + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Ensure that the JSON matches what we expect + ; this Sync Status should always be in progress + D ASSERT("1234V4321",$G(OBJECT("icn")),"icn attribute should exist") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Sync shouldn't be complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"SOLR Sync shouldn't be complete") + I $D(DATA) K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q + ; +GETSOLRMSITESCOMPLETENUM ;; @TEST Get multiple site complete Simple Patient Sync Status - Fully Numeric site hash with SOLR status + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; save off SOLR configuration + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","6242;3")="" + S ^VPRPTJ("JPID","6242;3")="52833885-af7c-4899-90be-b3a6630b2369" + D BASIC("6242",3) + D COMPLETEBASIC("6242",3) + D COMPLETEBASICSOLR("6242",3) + ; + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("6242;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("6242;3",ROOTJOBID,"completed",20160420110400,"vista-6242-subscribe-request") + D JOB("6242;3",ROOTJOBID,"completed",20160420110400,"vista-6242-data-allergy-poller") + ; + S ARG("icnpidjpid")="6242;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("",$G(OBJECT("icn")),"icn attribute should exist") + D ASSERT("true",$G(OBJECT("syncCompleted")),"SyncCompleted should exist") + D ASSERT("6242;3",$G(OBJECT("sites","""6242","pid")),"Site-pid 6242 should exist") + D ASSERT("true",$G(OBJECT("sites","""6242","syncCompleted")),"Site-Sync 6242 should be complete") + D ASSERT("true",$G(OBJECT("sites","""6242","solrSyncCompleted")),"Site-SOLR Sync 6242 should be complete") + I $D(DATA) K @DATA + K ^VPRPTJ("JPID") + D PATIDS + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q + ; +GETSOLREXCEPTIONS ;; @TEST Get Patient Simple Sync Status with SOLR domain exceptions + N DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("icnpidjpid")="SITE;3" + ; save off SOLR configuration + N SOLR,DOMAINEXCEPTIONS + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + M DOMAINEXCEPTIONS=^VPRCONFIG("sync","status","solr","domainExceptions") + K ^VPRCONFIG("sync","status","solr","domainExceptions") + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + ; Reset data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + ; Unset a SOLR stored item + K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrStored") + ; + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT(11,$D(OBJECT("icn")),"icn attribute should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","solrSyncCompleted")),"SOLR site sync shouldn't be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Sync should be complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"SOLR Sync shouldn't be complete") + ; + ; Try again with the vitals domain added to the exceptions list + S ^VPRCONFIG("sync","status","solr","domainExceptions","vitals")="" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Ensure that the JSON matches what we expect + D ASSERT(11,$D(OBJECT("icn")),"icn attribute should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"SOLR site sync should be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Sync should be complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"SOLR Sync should be complete") + ; + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + ; + ; Unset a different SOLR stored item + K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrStored") + ; + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT(11,$D(OBJECT("icn")),"icn attribute should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","solrSyncCompleted")),"SOLR site sync shouldn't be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Sync should be complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"SOLR Sync shouldn't be complete") + ; + ; Try again with the allergy domain added to the exceptions list + S ^VPRCONFIG("sync","status","solr","domainExceptions","allergy")="" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Ensure that the JSON matches what we expect + D ASSERT(11,$D(OBJECT("icn")),"icn attribute should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"SOLR site sync should be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Sync should be complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"SOLR Sync should be complete") + ; + I $D(DATA) K @DATA + K ^VPRPTJ("JPID") + D PATIDS + ; Reset SOLR configuration + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + K ^VPRCONFIG("sync","status","solr","domainExceptions") + M ^VPRCONFIG("sync","status","solr","domainExceptions")=DOMAINEXCEPTIONS + Q +STORERECORDUNKJPID ;; @TEST Manual Store flag ERROR if UNKNOWN JPID + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="1234;6" + S BODY("uid")="urn:va:vitals:1234:6:1234" + S BODY("eventStamp")=20141031094920 + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(404,$G(HTTPERR),"An HTTP 404 should have occured") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should have occured") + D ASSERT(224,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 224 reason code should have occured") + D ASSERT("",$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","1234;6","1234","vitals","urn:va:vitals:1234:6:1234",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("",$G(RETURN),"Returned a 201 instead of no data") + Q +STORERECORDUIDPID ;; @TEST Manual Store flag Mismatch between PID and UID + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:1234:6:1234" + S BODY("eventStamp")=20141031094920 + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT("1",$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:1234:6:1234",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("/vpr/SITE;3/urn:va:vitals:1234:6:1234",$G(RETURN),"Returned no data instead of a 201") + Q +STORERECORDND ;; @TEST Manual Store flag ERROR if UID invalid - no domain + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va::SITE:3" + S BODY("eventStamp")=20141031094920 + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(400,$G(HTTPERR),"An HTTP 400 should have occured") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should have occured") + D ASSERT(210,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 210 reason code should have occured") + D ASSERT("",$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("",$G(RETURN),"Returned a 201 instead of no data") + Q +STORERECORDNI ;; @TEST Manual Store flag ERROR if UID invalid - no ien + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vital:SITE:3" + S BODY("eventStamp")=20141031094920 + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(400,$G(HTTPERR),"An HTTP 400 should have occured") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should have occured") + D ASSERT(210,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 210 reason code should have occured") + D ASSERT("",$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("",$G(RETURN),"Returned a 201 instead of no data") + Q +STORERECORDUES ;; @TEST Manual Store flag ERROR if no eventStamp + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(400,$G(HTTPERR),"An HTTP 400 should have occured") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should have occured") + D ASSERT(210,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 210 reason code should have occured") + D ASSERT("",$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("",$G(RETURN),"Returned a 201 instead of no data") + Q +STORERECORDNES ;; @TEST Manual Store flag ERROR if eventStamp="" + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + S BODY("eventStamp")="" + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(400,$G(HTTPERR),"An HTTP 400 should have occured") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should have occured") + D ASSERT(210,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 210 reason code should have occured") + D ASSERT("",$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("",$G(RETURN),"Returned a 201 instead of no data") + Q +STORERECORDJDS ;; @TEST Manual Store flag is set for JDS + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + S BODY("eventStamp")=20141031094920 + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(1,$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("/vpr/SITE;3/urn:va:vitals:SITE:3:1002",$G(RETURN),"Return not a 201/no data returned") + Q +STORERECORDJDST ;; @TEST Manual Store flag is set for JDS with type field + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + S BODY("eventStamp")=20141031094920 + S BODY("type")="jds" + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(1,$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")),"JDS Stored flag doesn't exist") + D ASSERT("/vpr/SITE;3/urn:va:vitals:SITE:3:1002",$G(RETURN),"Return not a 201/no data returned") + Q +STORERECORDSOLR ;; @TEST Manual Store flag is set for SOLR + N BODY,RETURN,DATA,ARG,ERR,OBJECT,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + S BODY("eventStamp")=20141031094920 + S BODY("type")="solr" + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(1,$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")),"SOLR Stored flag doesn't exist") + D ASSERT("/vpr/SITE;3/urn:va:vitals:SITE:3:1002",$G(RETURN),"Return not a 201/no data returned") + Q +STORERECORDSOLRERR ;; @TEST Manual Store flag is set for solrError + N BODY,RETURN,DATA,ARG,ERR,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + S BODY("eventStamp")=20141031094920 + S BODY("type")="solrError" + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(1,$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")),"SOLR Error flag doesn't exist") + D ASSERT("/vpr/SITE;3/urn:va:vitals:SITE:3:1002",$G(RETURN),"Return not a 201/no data returned") + Q +STORERECORDSYNCERR ;; @TEST Manual Store flag is set for syncError + N BODY,RETURN,DATA,ARG,ERR,HTTPERR + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1002" + S BODY("eventStamp")=20141031094920 + S BODY("type")="syncError" + D ENCODE^VPRJSON("BODY","DATA","ERR") + K BODY,ERR + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT(1,$G(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")),"Sync Error flag doesn't exist") + D ASSERT("/vpr/SITE;3/urn:va:vitals:SITE:3:1002",$G(RETURN),"Return not a 201/no data returned") + Q + ; + ; SOLR and Sync error flag tests for Simple Sync Status + ; +GETSYNCERRORPARTSYNC ;; @TEST Get Patient Simple Sync Status with a Sync error after a partial sync + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + ; + I $D(DATA) K @DATA + ; Set Sync error flags + D COMPLETEBASICSYNCERR("SITE",3) + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(1,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(1,$D(OBJECT("hasError")),"Patient SITE;3 should have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + Q + ; +GETSOLRERRORPARTSYNC ;; @TEST Get Patient Simple Sync Status with a SOLR error after a partial sync + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + ; + I $D(DATA) K @DATA + ; Set SOLR error flags + D COMPLETEBASICSOLRERR("SITE",3) + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("false",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should not be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should not be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(1,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(1,$D(OBJECT("hasSolrError")),"Patient SITE;3 should have SOLR error") + Q + ; +GETSYNCSOLRERRORPARTSYNC ;; @TEST Get Patient Simple Sync Status with a Sync and a SOLR error after a partial sync + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + ; + I $D(DATA) K @DATA + ; Set Sync and SOLR error flags + D COMPLETEBASICSYNCERR("SITE",3) + D COMPLETEBASICSOLRERR("SITE",3) + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("false",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should not be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should not be SOLR sync complete") + D ASSERT(1,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should have Sync error") + D ASSERT(1,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should have SOLR error") + D ASSERT(1,$D(OBJECT("hasError")),"Patient SITE;3 should have Sync error") + D ASSERT(1,$D(OBJECT("hasSolrError")),"Patient SITE;3 should have SOLR error") + Q + ; +GETSYNCERRORFULLSYNC ;; @TEST Get Patient Simple Sync Status with a Sync error after a full sync + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Patient SITE;3 should be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + ; + I $D(DATA) K @DATA + ; Set Sync error flags + D COMPLETEBASICSYNCERR("SITE",3) + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(1,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(1,$D(OBJECT("hasError")),"Patient SITE;3 should have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + Q + ; +GETSOLRERRORFULLSYNC ;; @TEST Get Patient Simple Sync Status with a SOLR error after a full sync + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Patient SITE;3 should be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + ; + I $D(DATA) K @DATA + ; Set SOLR error flags + D COMPLETEBASICSOLRERR("SITE",3) + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should be complete") + D ASSERT("false",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should not be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Patient SITE;3 should be sync complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should not be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(1,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(1,$D(OBJECT("hasSolrError")),"Patient SITE;3 should have SOLR error") + Q + ; +GETSYNCSOLRERRORFULLSYNC ;; @TEST Get Patient Simple Sync Status with a Sync and a SOLR error after a full sync + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Patient SITE;3 should be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + ; + I $D(DATA) K @DATA + ; Set Sync and SOLR error flags + D COMPLETEBASICSYNCERR("SITE",3) + D COMPLETEBASICSOLRERR("SITE",3) + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("false",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should not be complete") + D ASSERT("false",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should not be complete") + D ASSERT("false",$G(OBJECT("syncCompleted")),"Patient SITE;3 should not be sync complete") + D ASSERT("false",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should not be SOLR sync complete") + D ASSERT(1,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should have Sync error") + D ASSERT(1,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should have SOLR error") + D ASSERT(1,$D(OBJECT("hasError")),"Patient SITE;3 should have Sync error") + D ASSERT(1,$D(OBJECT("hasSolrError")),"Patient SITE;3 should have SOLR error") + Q +RESETSYNCERROR ;; @TEST Get Patient Simple Sync Status with a Sync and a SOLR error after a full sync + N BODY,JPID,DATA,ARG,ERR,HTTPERR,STAMPTIME,RETURN + ; Set up solr error + D PATIDS + S JPID="52833885-af7c-4899-90be-b3a6630b2369" + S STAMPTIME=20141031094920 + S ARG("pid")="SITE;3" + S BODY("uid")="urn:va:vitals:SITE:3:1001",BODY("eventStamp")=STAMPTIME,BODY("type")="solrErr",BODY("pid")="SITE;3" + D ENCODE^VPRJSON("BODY","DATA","ERR") + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + ; Set status to stored + S BODY("type")="solr" + K DATA,ERR D ENCODE^VPRJSON("BODY","DATA","ERR") + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT("",$G(^VPRSTATUS(JPID,"SITE;3","SITE","vitals",BODY("uid"),STAMPTIME,"solrError")),"SOLR Error should have been cleared") + D ASSERT(1,$G(^VPRSTATUS(JPID,"SITE;3","SITE","vitals",BODY("uid"),STAMPTIME,"solrStored")),"SOLR status should be stored") + S BODY("uid")="urn:va:vitals:SITE:3:1002",BODY("type")="syncError" + K DATA,ERR D ENCODE^VPRJSON("BODY","DATA","ERR") + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + S BODY("type")="jds" + K DATA,ERR D ENCODE^VPRJSON("BODY","DATA","ERR") + S RETURN=$$STORERECORD^VPRJPSTATUS(.ARG,.DATA) + D ASSERT("",$G(^VPRSTATUS(JPID,"SITE;3","SITE","vitals",BODY("uid"),STAMPTIME,"syncError")),"Sync Error should have been cleared") + D ASSERT(1,$G(^VPRSTATUS(JPID,"SITE;3","SITE","vitals",BODY("uid"),STAMPTIME,"stored")),"Object should be stored") + Q +GET2NDTIME ;; @TEST 1st time Patient sync complete started ESR Job + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + ; + ; Create jobs + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"enterprise-sync-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-subscribe-request") + D JOB("SITE;3",ROOTJOBID,"completed",20160420110400,"vista-SITE-data-allergy-poller") + S ROOTJOBID=$$UUID^VPRJRUT + D JOB("SITE;3",ROOTJOBID,"started",20160420110405,"enterprise-sync-request") + ; + S ARG("icnpidjpid")="SITE;3" + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("SITE;3",$G(OBJECT("sites","SITE","pid")),"Site-pid SITE should exist") + D ASSERT("true",$G(OBJECT("sites","SITE","syncCompleted")),"Site-SYNC SITE should be complete") + D ASSERT("true",$G(OBJECT("sites","SITE","solrSyncCompleted")),"Site-SOLR Sync SITE should be complete") + D ASSERT(20141031094920,$G(OBJECT("sites","SITE","sourceStampTime")),"Site-sourceStampTime should have a value") + D ASSERT("true",$G(OBJECT("syncCompleted")),"Patient SITE;3 should be sync complete") + D ASSERT("true",$G(OBJECT("solrSyncCompleted")),"Patient SITE;3 should be SOLR sync complete") + D ASSERT(0,$D(OBJECT("sites","SITE","hasError")),"Site-SYNC SITE should not have Sync error") + D ASSERT(0,$D(OBJECT("sites","SITE","hasSolrError")),"Site-SOLR Sync SITE should not have SOLR error") + D ASSERT(0,$D(OBJECT("hasError")),"Patient SITE;3 should not have Sync error") + D ASSERT(0,$D(OBJECT("hasSolrError")),"Patient SITE;3 should not have SOLR error") + QUIT + ; + ; VLER-DAS tests +ASSERTJOBS(JOBS,PID,SYNCCOMPLETE,SYNCERROR,DEBUG) + ; JOBS Array format + ; JOBS(1,"JOB")="vler-das-sync-request" + ; JOBS(1,"STATUS")="error" + ; JOBS(1,"PID")="VLER;1234V4321" + ; JOBS(1,"TIMESTAMP")=20160420110400 + ; JOBS(2,"JOB")="vler-das-subscribe-request" + ; JOBS(2,"STATUS")="error" + ; JOBS(2,"PID")="VLER;1234V4321" + ; JOBS(2,"TIMESTAMP")=20160420110400 + N DATA,ARG,ERR,OBJECT,HTTPERR,ROOTJOBID,JOB + S DEBUG=$G(DEBUG) + ; + ; Set up test data + K ^VPRPTJ("JPID") + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","VLER;1234V4321")="" + S ^VPRPTJ("JPID","VLER;1234V4321")="52833885-af7c-4899-90be-b3a6630b2369" + ; + D BASIC("SITE",3) + D COMPLETEBASIC("SITE",3) + D COMPLETEBASICSOLR("SITE",3) + D BASIC("VLER","1234V4321") + D:SYNCCOMPLETE="true" COMPLETEBASIC("VLER","1234V4321") + D:SYNCCOMPLETE="true" COMPLETEBASICSOLR("VLER","1234V4321") + ; + ; Create jobs + S JOB="" + F S JOB=$O(JOBS(JOB)) Q:JOB="" D + . S ROOTJOBID=$$UUID^VPRJRUT + . D JOB(JOBS(JOB,"PID"),ROOTJOBID,JOBS(JOB,"STATUS"),JOBS(JOB,"TIMESTAMP"),JOBS(JOB,"JOB")) + ; + I DEBUG W !,"CALLING ENDPOINT" + S ARG("icnpidjpid")=PID + S ARG("debug")=1 + D COMBINED^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) D DECODE^VPRJSON(DATA,"OBJECT","ERR") + I DEBUG W !,"OBJECT",! ZWRITE OBJECT W ! + I DEBUG W !,"RULES",! ZWRITE ^||TMP($J) W ! + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + I DEBUG W !,"DOING ASSERTS" + I DEBUG W !,"SYNCCOMPLETE ",SYNCCOMPLETE + I DEBUG W ,"SYNCERROR ",SYNCERROR + I DEBUG W !,"SYNC STATUS",! ZWRITE ^VPRSTATUS + ; Ensure that the JSON matches what we expect + D ASSERT(PID,$G(OBJECT("sites",$P(PID,";",1),"pid")),"Site-pid "_$P(PID,";",1)_" should exist") + D ASSERT(SYNCCOMPLETE,$G(OBJECT("sites",$P(PID,";",1),"syncCompleted")),"Site-SYNC "_$P(PID,";",1)_" should "_$S(SYNCCOMPLETE="true":"",1:"not ")_"be complete") + D ASSERT(20141031094920,$G(OBJECT("sites",$P(PID,";",1),"sourceStampTime")),"Site-sourceStampTime "_$P(PID,";",1)_" should have a value") + D ASSERT($S(SYNCERROR="1":1,1:0),$D(OBJECT("sites",$P(PID,";",1),"hasError")),"Site-SYNC "_PID_" should "_$S(SYNCERROR="1":"",1:"not ")_"have Sync error") + D ASSERT($S(SYNCERROR="1":1,1:0),$D(OBJECT("hasError")),"Patient "_PID_" should "_$S(SYNCERROR="1":"",1:"not ")_"have Sync error") + QUIT +VDR1 ;; @TEST VLER-DAS Rule 1 + N JOBS + ; VDSR not complete (error) + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDSR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDSR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDSUR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDSUR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDDR not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-doc-retrieve" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDDR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDDR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-doc-retrieve" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDDR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-xform-vpr" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDDR not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDDR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDDR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDDR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-xform-vpr" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDXV not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-xform-vpr" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDXV started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR & VDDR not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSUR & VDDR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR & VDDR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR & VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-xform-vpr" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSUR & VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR & VDXV not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-xform-vpr" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDSUR & VDXV started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDDR & VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-doc-retrieve" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-xform-vpr" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDDR & VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDDR & VDXV not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-doc-retrieve" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-xform-vpr" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"VDDR & VDXV started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR & VDDR not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="error" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR & VDDR error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR & VDDR not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="started" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR & VDDR started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR & VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-xform-vpr" + S JOBS(3,"STATUS")="error" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR & VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR & VDXV not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-xform-vpr" + S JOBS(3,"STATUS")="started" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR & VDXV started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR & VDDR & VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-xform-vpr" + S JOBS(3,"STATUS")="error" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"VDSUR & VDDR & VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSUR & VDDR & VDXV not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-subscribe-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-xform-vpr" + S JOBS(3,"STATUS")="started" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"VDSUR & VDDR & VDXV started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; VDSR & VDSUR & VDDR & VDXV not complete (error) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="error" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="error" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="error" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + S JOBS(4,"JOB")="vler-das-xform-vpr" + S JOBS(4,"STATUS")="error" + S JOBS(4,"PID")="VLER;1234V4321" + S JOBS(4,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR & VDDR & VDXV error" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",1) + D ASSERT("",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + QUIT + ; + ; VDSR & VDSUR & VDDR & VDXV not complete (started) + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="vler-das-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="started" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="started" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + S JOBS(4,"JOB")="vler-das-xform-vpr" + S JOBS(4,"STATUS")="started" + S JOBS(4,"PID")="VLER;1234V4321" + S JOBS(4,"TIMESTAMP")=20160420110400 + W !,"VDSR & VDSUR & VDDR & VDXV started" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; ESR complete & VDSR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"ESR & VDSR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR complete & VDSUR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"ESR & VDSUR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; ESR complete & VDDR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"ESR complete & VDDR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; ESR complete & VDSR & VDSUR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-subscribe-request" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"ESR & VDSR & VDSUR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR complete & VDSR & VDDR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"ESR complete & VDSR & VDDR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; ESR complete & VDSUR & VDDR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"ESR complete & VDSUR & VDDR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't false") + ; + ; ESR Started & VDSR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDSR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR Started & VDSUR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-doc-retrieve" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDSUR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR Started & VDDR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-subscribe-request" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDDR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR Started & VDSR & VDSUR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-doc-retrieve" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDSR & VDSUR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR Started & VDSR & VDDR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-subscribe-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDSR & VDDR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR Started & VDSUR & VDDR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDSUR & VDDR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 1 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + QUIT +VDR2 ;; @TEST VLER-DAS Rule 2 + ; This rule requires enterprise-sync-request to be completed in all cases and at least one vler-das job to exist to run + N JOBS + ; ESR complete & VDSR & VDSUR & VDDR complete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-subscribe-request" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + S JOBS(4,"JOB")="vler-das-doc-retrieve" + S JOBS(4,"STATUS")="completed" + S JOBS(4,"PID")="VLER;1234V4321" + S JOBS(4,"TIMESTAMP")=20160420110400 + W !,"ESR complete & VDSR & VDSUR & VDDR complete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","true",0) + D ASSERT("VLER DAS RULE 2 TRUE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + ; + ; ESR & VDSR & VDSUR & VDDR complete, metastamp incomplete + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="completed" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + S JOBS(2,"JOB")="vler-das-sync-request" + S JOBS(2,"STATUS")="completed" + S JOBS(2,"PID")="VLER;1234V4321" + S JOBS(2,"TIMESTAMP")=20160420110400 + S JOBS(3,"JOB")="vler-das-subscribe-request" + S JOBS(3,"STATUS")="completed" + S JOBS(3,"PID")="VLER;1234V4321" + S JOBS(3,"TIMESTAMP")=20160420110400 + S JOBS(4,"JOB")="vler-das-doc-retrieve" + S JOBS(4,"STATUS")="completed" + S JOBS(4,"PID")="VLER;1234V4321" + S JOBS(4,"TIMESTAMP")=20160420110400 + W !,"ESR & VDSR & VDSUR & VDDR & VDXV completed, metastamp incomplete" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER DAS RULE 2 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + QUIT +VDR3 ;; @TEST VLER-DAS Rule 3 + N JOBS + ; Base assumption is that an ESR has to exist at one point, else there is nothing to test. + ; If ESR is in error then Rule 3 will never execute due to fail fast methodologies. + ; + ; ESR Started & VDSR & VDSUR & VDDR doesn't exist rest exist + D TEARDOWN + K JOBS + S JOBS(1,"JOB")="enterprise-sync-request" + S JOBS(1,"STATUS")="started" + S JOBS(1,"PID")="VLER;1234V4321" + S JOBS(1,"TIMESTAMP")=20160420110400 + W !,"ESR Started & VDSR & VDSUR & VDDR doesn't exist rest exist" + D ASSERTJOBS(.JOBS,"VLER;1234V4321","false",0) + D ASSERT("VLER RULE 3 FALSE",$G(^||TMP($J,"RESULT","return","RULES","VLER")),"Expected rule isn't true") + QUIT + ; +GETDOMAINJOBSNOTIMESTAMP ;; @TEST GETDOMAINJOBS works when no JOB TIMESTAMP exists + ; This is technically an invalid scenario, but if it does happen we shouldn't generate a hard error + N JOB,ROOTJOBID,U,VDJOBS + S U="^" + S ROOTJOBID=$$UUID^VPRJRUT + S JOB("jobId")=$$UUID^VPRJRUT + S JOB("jpid")="52833885-af7c-4899-90be-b3a6630b2369" + S JOB("patientIdentifier","type")="pid" + S JOB("patientIdentifier","value")="SITE;3" + S JOB("rootJobId")=ROOTJOBID + S JOB("status")="completed" + S JOB("type")="vista-SITE-data-poller" + S VPRCNT=$I(^VPRJOB(0)) + S ^VPRJOB("A",JOB("jpid"),JOB("type"),JOB("rootJobId"),JOB("jobId"),11111,JOB("status"))=VPRCNT + S ^VPRJOB("B",VPRCNT)=JOB("jpid")_U_JOB("type")_U_JOB("rootJobId")_U_JOB("jobId")_U_11111_U_JOB("status") + S ^VPRJOB("C",JOB("jobId"),JOB("rootJobId"))="" + S ^VPRJOB("D",JOB("jpid"),JOB("type"),11111,VPRCNT)=VPRCNT + M ^VPRJOB(VPRCNT)=JOB + D GETDOMAINJOBS^VPRJPSTATUS(.VDJOBS,JOB("jpid"),"vista-SITE-data-") + D ASSERT(10,$D(VDJOBS),"No jobs returned") + QUIT diff --git a/VPRJTQP.m b/VPRJTQP.m new file mode 100644 index 0000000..32d5717 --- /dev/null +++ b/VPRJTQP.m @@ -0,0 +1,204 @@ +VPRJTQP ;V4W/DLW -- Integration tests for POST queries + ; +STARTUP ; Run once before all tests + N I,TAGS + F I=1:1:5 S TAGS(I)="MED"_I_"^VPRJTP02" + D BLDPT^VPRJTX(.TAGS) + QUIT + ; +SHUTDOWN ; Run once after all tests + D CLRPT^VPRJTX + K ^VPRPTJ + K ^VPRPT + K ^VPRMETA("JPID") + K ^||TMP + QUIT + ; +SETUP ; Run before each test + K HTTPREQ,HTTPERR,HTTPRSP,^||TMP + QUIT + ; +TEARDOWN ; Run after each test + K HTTPREQ,HTTPERR,HTTPRSP,^||TMP + QUIT + ; +ASSERT(EXPECT,ACTUAL,MSG) ; convenience + D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) + QUIT + ; +POSTQUERY ;; @TEST POST query with a big (1004 chars) filter on an index + ; filter just over the 1000 character limit some browsers and proxies have + N HTTPERR,JSON,VPRJPID + S VPRJPID=$$JPID4PID^VPRJPR("93EF;-7") + D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") + I $G(VPRJPID)="" QUIT + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTFILTER","VPRJTP04") + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(4,$G(JSON("data","totalItems"))) + D ASSERT("PHARMACIST,ONE",$G(JSON("data","items",1,"orders",1,"pharmacist","name"))) + D ASSERT("TAB,SA",$G(JSON("data","items",2,"productFormName"))) + D ASSERT("WARFARIN",$G(JSON("data","items",3,"products",1,"ingredientName"))) + D ASSERT("NON-OPIOID ANALGESICS",$G(JSON("data","items",4,"products",1,"drugClassName"))) + QUIT + ; +POSTQUERY2 ;; @TEST POST query with a large (2090 chars) filter on an index + ; filter just over the 2083 character limit some browsers and proxies have + N HTTPERR,JSON,VPRJPID,I,J,K,L,LAST,DATA + S VPRJPID=$$JPID4PID^VPRJPR("93EF;-7") + D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") + I $G(VPRJPID)="" QUIT + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTFILTER","VPRJTP04") + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-2)_"," + F I=LAST:1:12 D + . K DATA + . D GETDATA^VPRJTX("POSTFILTER","VPRJTP04",.DATA) + . S DATA(1)=$E(DATA(1),12,$L(DATA(1))) + . S L=$O(DATA(""),-1) + . S DATA(L)=$E(DATA(L),1,$L(DATA(L))-2)_"," + . S J=0 + . F K=I+1:1 S J=$O(DATA(J)) Q:J="" D + . . S HTTPREQ("body",K)=DATA(J) + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-1)_"""}" + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(4,$G(JSON("data","totalItems"))) + D ASSERT("PHARMACIST,ONE",$G(JSON("data","items",1,"orders",1,"pharmacist","name"))) + D ASSERT("TAB,SA",$G(JSON("data","items",2,"productFormName"))) + D ASSERT("WARFARIN",$G(JSON("data","items",3,"products",1,"ingredientName"))) + D ASSERT("NON-OPIOID ANALGESICS",$G(JSON("data","items",4,"products",1,"drugClassName"))) + QUIT + ; +POSTQUERY3 ;; @TEST POST query with a massive (3640934 chars) filter on an index + ; filter just under the limit (3641000) on a string in the POST query processor (set lower than a string limit in Cache - 3641144) + N HTTPERR,JSON,VPRJPID,I,J,K,L,LAST,DATA + S VPRJPID=$$JPID4PID^VPRJPR("93EF;-7") + D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") + I $G(VPRJPID)="" QUIT + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTFILTER","VPRJTP04") + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-2)_"," + F I=LAST:1:44936 D + . K DATA + . D GETDATA^VPRJTX("POSTFILTER","VPRJTP04",.DATA) + . S DATA(1)=$E(DATA(1),12,$L(DATA(1))) + . S L=$O(DATA(""),-1) + . S DATA(L)=$E(DATA(L),1,$L(DATA(L))-2)_"," + . S J=0 + . F K=I+1:1 S J=$O(DATA(J)) Q:J="" D + . . S HTTPREQ("body",K)=DATA(J) + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-1)_"""}" + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(4,$G(JSON("data","totalItems"))) + D ASSERT("PHARMACIST,ONE",$G(JSON("data","items",1,"orders",1,"pharmacist","name"))) + D ASSERT("TAB,SA",$G(JSON("data","items",2,"productFormName"))) + D ASSERT("WARFARIN",$G(JSON("data","items",3,"products",1,"ingredientName"))) + D ASSERT("NON-OPIOID ANALGESICS",$G(JSON("data","items",4,"products",1,"drugClassName"))) + QUIT + ; +POSTQUERY4 ;; @TEST POST query with a massive (3640934 chars) filter on an index with start and limit set + ; filter just under the limit (3641000) on a string in the POST query processor (set lower than a string limit in Cache - 3641144) + ; then test the start and limit parameters + N HTTPERR,JSON,VPRJPID,I,J,K,L,LAST,DATA + S VPRJPID=$$JPID4PID^VPRJPR("93EF;-7") + D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") + I $G(VPRJPID)="" QUIT + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTFILTER","VPRJTP04") + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-2)_"," + F I=LAST:1:44936 D + . K DATA + . D GETDATA^VPRJTX("POSTFILTER","VPRJTP04",.DATA) + . S DATA(1)=$E(DATA(1),12,$L(DATA(1))) + . S L=$O(DATA(""),-1) + . S DATA(L)=$E(DATA(L),1,$L(DATA(L))-2)_"," + . S J=0 + . F K=I+1:1 S J=$O(DATA(J)) Q:J="" D + . . S HTTPREQ("body",K)=DATA(J) + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-1)_"""," + S HTTPREQ("body",LAST)=HTTPREQ("body",LAST)_"""start"":1,""limit"":2}" + D RESPOND^VPRJRSP + D ASSERT(0,$G(HTTPERR)) + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(2,$G(JSON("data","currentItemCount"))) + D ASSERT(4,$G(JSON("data","totalItems"))) + D ASSERT("PHARMACIST,THIRTY",$G(JSON("data","items",1,"orders",1,"pharmacist","name"))) + D ASSERT("METFORMIN",$G(JSON("data","items",1,"products",1,"ingredientName"))) + D ASSERT("TAB,SA",$G(JSON("data","items",1,"productFormName"))) + D ASSERT("ORAL HYPOGLYCEMIC AGENTS,ORAL",$G(JSON("data","items",1,"products",1,"drugClassName"))) + D ASSERT("not active",$G(JSON("data","items",2,"medStatusName"))) + D ASSERT("urn:sct:73639000",$G(JSON("data","items",2,"medType"))) + D ASSERT("VEHU,ONEHUNDRED",$G(JSON("data","items",2,"orders",1,"provider","name"))) + D ASSERT("DISCONTINUED",$G(JSON("data","items",2,"orders",1,"vaOrderStatus"))) + QUIT + ; +POSTQUERY5 ;; @TEST POST query with a massive (3640953 chars) filter on an index + ; filter just over the limit (3641000) on a string in the POST query processor (set lower than a string limit in Cache - 3641144) + N HTTPERR,JSON,VPRJPID,I,J,K,L,LAST,DATA + S VPRJPID=$$JPID4PID^VPRJPR("93EF;-7") + D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") + I $G(VPRJPID)="" QUIT + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTFILTER","VPRJTP04") + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-2)_"," + F I=LAST:1:44937 D + . K DATA + . D GETDATA^VPRJTX("POSTFILTER","VPRJTP04",.DATA) + . S DATA(1)=$E(DATA(1),12,$L(DATA(1))) + . S L=$O(DATA(""),-1) + . S DATA(L)=$E(DATA(L),1,$L(DATA(L))-2)_"," + . S J=0 + . F K=I+1:1 S J=$O(DATA(J)) Q:J="" D + . . S HTTPREQ("body",K)=DATA(J) + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-1)_"""}" + D RESPOND^VPRJRSP + D ASSERT(413,^||TMP("HTTPERR",$J,1,"error","code"),"Should be HTTP 413 error, but it is not") + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(0,$D(JSON("data"))) + D ASSERT("POST query parameters exceed argument length limit",^||TMP("HTTPERR",$J,1,"error","errors",1,"domain")) + D ASSERT("Parameter length limit exceeded",^||TMP("HTTPERR",$J,1,"error","errors",1,"message")) + D ASSERT(114,^||TMP("HTTPERR",$J,1,"error","errors",1,"reason"),"Should be JDS 114 error reason, but it is not") + D ASSERT("Request entity too large",^||TMP("HTTPERR",$J,1,"error","message")) + QUIT + ; +POSTQUERY6 ;; @TEST POST query with a massive (3640934 chars) filter on an index, with other parameters go over the limit (3641013) + ; filter just under the limit (3641000) on a string in the POST query processor (set lower than a string limit in Cache - 3641144) + ; then add start, limit, and order parameters to put it over the limit + N HTTPERR,JSON,VPRJPID,I,J,K,L,LAST,DATA + S VPRJPID=$$JPID4PID^VPRJPR("93EF;-7") + D ASSERT(1,$G(VPRJPID)'="","JPID doesn't exist for this patient") + I $G(VPRJPID)="" QUIT + D SETPOST^VPRJTX("/vpr/"_VPRJTPID_"/index/med-time/?query=true","POSTFILTER","VPRJTP04") + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-2)_"," + F I=LAST:1:44936 D + . K DATA + . D GETDATA^VPRJTX("POSTFILTER","VPRJTP04",.DATA) + . S DATA(1)=$E(DATA(1),12,$L(DATA(1))) + . S L=$O(DATA(""),-1) + . S DATA(L)=$E(DATA(L),1,$L(DATA(L))-2)_"," + . S J=0 + . F K=I+1:1 S J=$O(DATA(J)) Q:J="" D + . . S HTTPREQ("body",K)=DATA(J) + S LAST=$O(HTTPREQ("body",""),-1) + S HTTPREQ("body",LAST)=$E(HTTPREQ("body",LAST),1,$L(HTTPREQ("body",LAST))-1)_"""," + S HTTPREQ("body",LAST)=HTTPREQ("body",LAST)_"""start"":0,""limit"":1000000000000000000000000000000000000000," + S HTTPREQ("body",LAST)=HTTPREQ("body",LAST)_"""order"":""sig asc, kind desc, overallStop""}" + D RESPOND^VPRJRSP + D ASSERT(413,^||TMP("HTTPERR",$J,1,"error","code"),"Should be HTTP 413 error, but it is not") + D DATA2ARY^VPRJTX(.JSON) + D ASSERT(0,$D(JSON("data"))) + D ASSERT("POST query parameters exceed argument length limit",^||TMP("HTTPERR",$J,1,"error","errors",1,"domain")) + D ASSERT("Parameter length limit exceeded",^||TMP("HTTPERR",$J,1,"error","errors",1,"message")) + D ASSERT(114,^||TMP("HTTPERR",$J,1,"error","errors",1,"reason"),"Should be JDS 114 error reason, but it is not") + D ASSERT("Request entity too large",^||TMP("HTTPERR",$J,1,"error","message")) + QUIT diff --git a/VPRJTSES.m b/VPRJTSES.m old mode 100755 new mode 100644 index 243fb02..0c46b26 --- a/VPRJTSES.m +++ b/VPRJTSES.m @@ -27,10 +27,10 @@ S BODY(1)=BODY(1)_":" ; Send it to the URL S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETIDRR ;; @TEST Error code is set if no ID N RETURN,BODY,ARG,HTTPERR @@ -38,31 +38,31 @@ D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason S BODY(1)=$$SITEOD("","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(220,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(220,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Try with a non existant _id field S BODY(1)="{""ZZUT"": ""20150127-1000""}" S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") - D ASSERT(220,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 error should have occured") + D ASSERT(220,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 220 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SET1 ;; @TEST Store one Session Data N RETURN,BODY,ARG,HTTPERR S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup ^VPRJSES K ^VPRJSES("ZZUT") I $G(^VPRJSES(0))>0 S ^VPRJSES(0)=^VPRJSES(0)-1 @@ -72,33 +72,33 @@ D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Run it again with a new lastUpdate time S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1500") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1500",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,BODY,ARG ; Run it again with a new lastUpdate time that is smaller S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-25") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-25",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup ^VPRJSES K ^VPRJSES("ZZUT") I $G(^VPRJSES(0))>0 S ^VPRJSES(0)=^VPRJSES(0)-3 @@ -109,10 +109,10 @@ D ASSERT("20150127-25",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field w D DEL^VPRJSES(.DATA,.ARGS) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup vars K DATA,OBJECT,ERR,ARGS ; Try with a blank _id @@ -120,10 +120,10 @@ S ARGS("_id")="" D DEL^VPRJSES(.DATA,.ARGS) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q DEL ;; @TEST Delete Session Data N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -131,11 +131,11 @@ D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now delete it @@ -145,7 +145,7 @@ S ARGS("_id")="ZZUT" D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q LEN ;; @TEST Get number of Session Data N RETURN,BODY,ARG,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -153,42 +153,42 @@ D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now get length D LEN^VPRJSES(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error Occured") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") D ASSERT(1,$G(OBJECT("length")),"The total number of objects doesn't match1") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K OBJECT,DATA,ERR,ARGS ; Create Session Data S BODY(1)=$$SITEOD("ZZUT1","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"A Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K BODY,RETURN,ARG ; Now get length D LEN^VPRJSES(.DATA,.ARGS) D DECODE^VPRJSON("DATA","OBJECT","ERR") - D ASSERT(0,$D(^TMP("HTTPERR",$J)),"An HTTP Error Occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J)),"An HTTP Error Occured") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") D ASSERT(2,$G(OBJECT("length")),"The total number of objects doesn't match2") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup ^VPRJSES K ^VPRJSES("ZZUT") K ^VPRJSES("ZZUT1") @@ -200,10 +200,10 @@ D ASSERT(2,$G(OBJECT("length")),"The total number of objects doesn't match2") D GET^VPRJSES(.DATA,.ARGS) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,OBJECT,ARGS ; Try with a null id @@ -211,20 +211,20 @@ S ARGS("_id")="" D GET^VPRJSES(.DATA,.ARGS) D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(111,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(111,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 111 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q GETJSONERR ;; Error code is set if encoding to JSON fails N DATA,ARGS,OBJECT,HTTPERR S ARGS("_id")="ZZUT" D GET^VPRJSES(.DATA,.ARGS) D ASSERT(0,$D(DATA),"No DATA should be returned") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") - D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 error should have occured") + D ASSERT(202,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason code should have occurred") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q GET ;; @TEST Get Session Data N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR @@ -232,11 +232,11 @@ D ASSERT(202,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"An 202 reason S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored @@ -245,22 +245,22 @@ S ARGS("_id")="ZZUT" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJSES("ZZUT")),"Session Data does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("20150127-1000",$G(OBJECT("lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR ; Create Session Data update S BODY(1)=$$SITEOD("ZZUT","lastUpdate","20150127-1500") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT")),"Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(^VPRJSES("ZZUT","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1500",$G(^VPRJSES("ZZUT","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored update @@ -269,22 +269,22 @@ S ARGS("_id")="ZZUT" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJSES("ZZUT")),"Session Data does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("20150127-1500",$G(OBJECT("lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K DATA,ARGS,OBJECT,ERR ; Create second Session Data S BODY(1)=$$SITEOD("ZZUT1","lastUpdate","20150127-1000") S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ZZUT1")),"Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT1",$G(^VPRJSES("ZZUT1","_id")),"The _id field was not stored correctly") D ASSERT("20150127-1000",$G(^VPRJSES("ZZUT1","lastUpdate")),"The lastUpdate field was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get second Session Data @@ -293,11 +293,11 @@ S ARGS("_id")="ZZUT1" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJSES("ZZUT1")),"Session Data does not exists and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ZZUT1",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("20150127-1000",$G(OBJECT("lastUpdate")),"returned data for lastUpdate didn't match") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; leave these around so they can be killed in the next test Q CLR ;; @TEST Clear ALL Session Data @@ -308,21 +308,21 @@ D ASSERT(0,$D(^VPRJSES("ZZUT")),"A Session Data exists and it should not") D ASSERT("{}",$G(DATA),"DATA returned from a DELETE call (should not happen)") D ASSERT(10,$D(^VPRJSES),"Global not cleared") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q REAL ;; @TEST with realistic data N RETURN,ARG,BODY,DATA,ARGS,OBJECT,ERR,HTTPERR ; Create Session Data - S BODY(1)="{""_id"":""ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4"",""session"":{""cookie"":{""originalMaxAge"":900000,""expires"":""2015-01-30T04:38:30.084Z"",""httpOnly"":true,""path"":""/""},""user"":{""accessCode"":""PW "",""verifyCode"":""PW !!"",""username"":""9E7A;PW "",""password"":""PW !!"",""firstname"":""PANORAMA"",""lastname"":""USER"",""facility"":""PANORAMA"",""vistaKeys"":[""XUPROG"",""PROVIDER"",""GMRA-SUPERVISOR"",""ORES"",""GMRC101"",""XUPROGMODE"",""GMV MANAGER"",""PSB CPRS MED BUTTON""],""title"":""Clinician"",""section"":""Medicine"",""disabled"":false,""requiresReset"":false,""divisionSelect"":false,""dgRecordAccess"":""false"",""dgSensitiveAccess"":""false"",""dgSecurityOfficer"":""false"",""duz"":{""9E7A"":""10000000226""},""site"":""9E7A"",""ssn"":""666441233"",""corsTabs"":""true"",""rptTabs"":""false"",""permissions"":[""edit-patient-record"",""add-patient-allergy"",""remove-patient-allergy"",""add-patient-vital"",""remove-patient-vital"",""add-patient-med"",""edit-patient-med"",""remove-patient-med"",""add-patient-problem"",""edit-patient-problem"",""remove-patient-problem"",""add-patient-laborder"",""edit-patient-laborder"",""remove-patient-laborder"",""add-patient-radiology"",""edit-patient-radiology"",""remove-patient-radiology"",""patient-visit"",""add-patient-order"",""add-patient-immunization"",""edit-patient-demographics""]}},""expires"":""2015-01-30T04:38:30.084Z""}" + S BODY(1)="{""_id"":""ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4"",""session"":{""cookie"":{""originalMaxAge"":900000,""expires"":""2015-01-30T04:38:30.084Z"",""httpOnly"":true,""path"":""/""},""user"":{""accessCode"":""USER "",""verifyCode"":""PW "",""username"":""PW "",""password"":""PW "",""firstname"":""PANORAMA"",""lastname"":""USER"",""facility"":""PANORAMA"",""vistaKeys"":[""XUPROG"",""PROVIDER"",""GMRA-SUPERVISOR"",""ORES"",""GMRC101"",""XUPROGMODE"",""GMV MANAGER"",""PSB CPRS MED BUTTON""],""title"":""Clinician"",""section"":""Medicine"",""disabled"":false,""requiresReset"":false,""divisionSelect"":false,""dgRecordAccess"":""false"",""dgSensitiveAccess"":""false"",""dgSecurityOfficer"":""false"",""duz"":{""SITE"":""10000000226""},""site"":""SITE"",""ssn"":""666441233"",""corsTabs"":""true"",""rptTabs"":""false"",""permissions"":[""edit-patient-record"",""add-patient-allergy"",""remove-patient-allergy"",""add-patient-vital"",""remove-patient-vital"",""add-patient-med"",""edit-patient-med"",""remove-patient-med"",""add-patient-problem"",""edit-patient-problem"",""remove-patient-problem"",""add-patient-laborder"",""edit-patient-laborder"",""remove-patient-laborder"",""add-patient-radiology"",""edit-patient-radiology"",""remove-patient-radiology"",""patient-visit"",""add-patient-order"",""add-patient-immunization"",""edit-patient-demographics""]}},""expires"":""2015-01-30T04:38:30.084Z""}" S RETURN=$$SET^VPRJSES(.ARG,.BODY) D ASSERT(10,$D(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4")),"Session Data does not exist and it should") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP error should NOT have occured") D ASSERT("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4",$G(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4","_id")),"The _id field was not stored correctly") D ASSERT("900000",$G(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4","session","cookie","originalMaxAge")),"returned data for sessin cookie originalMaxAge didn't match") - D ASSERT("10000000226",$G(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4","session","user","duz","9E7A")),"The user duz 9E7A field was not stored correctly") + D ASSERT("10000000226",$G(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4","session","user","duz","SITE")),"The user duz SITE field was not stored correctly") D ASSERT("XUPROG",$G(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4","session","user","vistaKeys",1)),"The user vistaKeys array was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Cleanup Vars K RETURN,ARG,BODY ; Get the data we stored @@ -331,12 +331,12 @@ S ARGS("_id")="ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4" D DECODE^VPRJSON("DATA","OBJECT","ERR") D ASSERT(10,$D(^VPRJSES("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4")),"Session Data does not exist and it should") D ASSERT(0,$D(ERR),"A JSON Decode Error Occured") - D ASSERT(0,$D(^TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") + D ASSERT(0,$D(^||TMP("HTTPERR",$J,1,"error")),"An HTTP error should NOT have occured") D ASSERT("ebTxc-5Zqn6qup8LGwf4deTrJRGIw1y4",$G(OBJECT("_id")),"returned data for the wrong _id") D ASSERT("900000",$G(OBJECT("session","cookie","originalMaxAge")),"returned data for sessin cookie originalMaxAge didn't match") - D ASSERT("10000000226",$G(OBJECT("session","user","duz","9E7A")),"The user duz 9E7A field was not stored correctly") + D ASSERT("10000000226",$G(OBJECT("session","user","duz","SITE")),"The user duz SITE field was not stored correctly") D ASSERT("XUPROG",$G(OBJECT("session","user","vistaKeys",1)),"The user vistaKeys array was not stored correctly") ; Cleanup HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D CLR^VPRJSES(.DATA,.ARGS) Q diff --git a/VPRJTSYNCOD.m b/VPRJTSYNCOD.m old mode 100755 new mode 100644 index 92fce77..167ff6d --- a/VPRJTSYNCOD.m +++ b/VPRJTSYNCOD.m @@ -10,12 +10,12 @@ STARTUP ; Run once before all tests K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SHUTDOWN ; Run once after all tests K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q ASSERT(EXPECT,ACTUAL,MSG) ; for convenience D EQ^VPRJT(EXPECT,ACTUAL,$G(MSG)) @@ -27,107 +27,107 @@ S RETURN(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { """_SIT SETNSITE ;; @TEST Error code is set if no site N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Null Site D SYNCSTAT(.BODY,"") S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(227,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 227 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(227,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 227 error should exist") ; Non-existant Site K BODY,ARG,RETURN - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"") S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(227,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 227 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(227,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 227 error should exist") ; Cleanup Vars K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETNSRCST ;; @TEST Error code is set if no source stampTime N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Null source stampTime S BODY(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { ""ZZUT"": { ""stampTime"": """",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""20141031094924"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""itemMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": ""20141031094926"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") ; Cleanup Vars K RETURN,ARG,BODY K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Non-existant source stampTime S BODY(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { ""ZZUT"": { ""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""20141031094924"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""itemMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": ""20141031094926"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") ; Cleanup Vars K RETURN,ARG,BODY K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETNDOMST ;; @TEST Error code is set if no domain stampTime N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Null domain stampTime S BODY(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { ""ZZUT"": { ""stampTime"": ""20141031094921"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": """",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""20141031094924"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""itemMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": ""20141031094926"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") ; Cleanup Vars K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Non-existant domain stampTime S BODY(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { ""ZZUT"": { ""stampTime"": ""20141031094921"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""20141031094924"" } } },""vitals"": { ""domain"": ""vitals"",""itemMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": ""20141031094926"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") ; Cleanup Vars K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETNITMST ;; @TEST Error code is set if no item stampTime N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Null item stampTime S BODY(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { ""ZZUT"": { ""stampTime"": ""20141031094921"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""20141031094924"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""itemMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": """" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") ; Cleanup Vars K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Non-existant item stampTime S BODY(1)=" { ""stampTime"": ""20141031094920"",""sourceMetaStamp"": { ""ZZUT"": { ""stampTime"": ""20141031094921"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""20141031094924"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""itemMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""something"":""test"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"An Operational Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") ; Cleanup Vars K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) Q SETONE ;; @TEST SET one site operational Sync Status N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"ZZUT") S ARG("id")="ZZUT" S ARG("detailed")="true" @@ -143,7 +143,7 @@ D ASSERT(1,$D(^VPRSTATUSOD("ZZUT","vitals","urn:va:vitals:ZZUT:1002",20141031094 ; Cleanup Vars K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Run single test again with 1ZZUT D SYNCSTAT(.BODY,"1ZZUT") S ARG("id")="1ZZUT" @@ -162,7 +162,7 @@ D ASSERT(1,$D(^VPRSTATUSOD("1ZZUT","vitals","urn:va:vitals:1ZZUT:1002",201410310 N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; ZZUT D SYNCSTAT(.BODY,"ZZUT") S ARG("id")="ZZUT" @@ -194,39 +194,39 @@ D ASSERT(1,$D(^VPRSTATUSOD("1ZZUT","vitals","urn:va:vitals:1ZZUT:1002",201410310 N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Null Site S ARG("id")="" D GET^VPRJDSTATUS(.BODY,.ARG) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"A Operational Data Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(241,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 241 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(241,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 241 error should exist") ; Non-existant Site K ARG,BODY - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D GET^VPRJDSTATUS(.BODY,.ARG) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"A Operational Data Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(241,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 241 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(241,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 241 error should exist") Q GETBJSONE ;; Error code is set if JSON can't be encoded N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Null Site S ARG("id")="" D GET^VPRJDSTATUS(.BODY,.ARG) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"A Operational Data Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(211,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") ; Non-existant Site D SYNCSTAT(.BODY,"") S ARG("id")="" D GET^VPRJDSTATUS(.BODY,.ARG) D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"A Operational Data Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(211,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") Q BLANK ; basic sync status K ^VPRSTATUSOD @@ -288,7 +288,7 @@ D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error s ; GETINITIAL ;; @TEST Get Initial Operational Data Sync Status N DATA,ARG,ERR,OBJECT,HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D BLANK S ARG("id")="ZZUT" S ARG("detailed")="true" @@ -730,7 +730,7 @@ D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","1ZZUT","syncCompleteAsO ; GETFILTER ;; @TEST Get Operational Data Sync Status with filters N DATA,ARG,ERR,OBJECT,HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D BLANK3 ; S ARG("id")="ZZUT" @@ -812,7 +812,7 @@ D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","ZZUT","domainMetaStamp" N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Store some data so we can delete it D SYNCSTAT(.BODY,"ZZUT") S ARG("id")="ZZUT" @@ -848,7 +848,7 @@ D ASSERT(1,$D(^VPRSTATUSOD("1ZZUT","vitals","urn:va:vitals:1ZZUT:1002",201410310 N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUSOD("ZZUT") K ^VPRSTATUSOD("1ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"ZZUT") S ARG("id")="ZZUT" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) @@ -879,7 +879,7 @@ D ASSERT(0,$D(^VPRSTATUSOD("1ZZUT","vitals","urn:va:vitals:1ZZUT:1002",201410310 N DATA,ARG,ERR,OBJECT,RETURN,BODY,HTTPERR ; Store the data K ^VPRSTATUSOD("DBCA") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)="{""stampTime"": ""20141031094920"",""sourceMetaStamp"": {""DCBA"": {""stampTime"": ""20141031094920"",""domainMetaStamp"": {""doc-def"": {""domain"": ""doc-def"",""stampTime"": ""20141031094920"",""itemMetaStamp"": {""urn:va:doc-def:DCBA:1001"": {""stampTime"": ""20141031094920"" },""urn:va:doc-def:DCBA:1002"": {""stampTime"": ""20141031094920"",}}},""pt-select"": {""domain"": ""pt-select"",""stampTime"": ""20141031094920"",""itemMetaStamp"": {""urn:va:pt-select:DCBA:1001"": {""stampTime"": ""20141031094920"",},""urn:va:pt-select:DCBA:1002"": {""stampTime"": ""20141031094920"",}}}}}}}" S ARG("id")="DBCA" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) @@ -926,7 +926,7 @@ D ASSERT(0,$D(^VPRSTATUSOD("ZZUT")),"CALL TO DEL^VPRJDSTATUS FAILED WITH AN ERRO N DATA,ARG,ERR,OBJECT,RETURN,BODY,JSON,RSLT,HTTPERR ; Store the data K ^VPRSTATUSOD("DBCA") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)="{""stampTime"": ""20141031094920"",""sourceMetaStamp"": {""DCBA"": {""stampTime"": ""20141031094920"",""domainMetaStamp"": {""doc-def"": {""domain"": ""doc-def"",""stampTime"": ""20141031094920"",""itemMetaStamp"": {""urn:va:doc-def:DCBA:1001"": {""stampTime"": ""20141031094920"" },""urn:va:doc-def:DCBA:1002"": {""stampTime"": ""20141031094920"",}}},""pt-select"": {""domain"": ""pt-select"",""stampTime"": ""20141031094920"",""itemMetaStamp"": {""urn:va:pt-select:DCBA:1001"": {""stampTime"": ""20141031094920"",},""urn:va:pt-select:DCBA:1002"": {""stampTime"": ""20141031094920"",}}}}}}}" S ARG("id")="DBCA" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) @@ -1022,10 +1022,12 @@ D ASSERT("",$G(^VPRSTATUSOD("ZZUT","stampTime")),"CALL TO DEL^VPRJDSTATUS FAILED K ^VPRJDJ("JSON","urn:va:pt-select:DCBA:1002") K ^VPRJD("urn:va:pt-select:DCBA:1002") Q -SETERRLCK ;; @TEST Error due locked event (2 second wait) +SETERRLCK ;; TEST Error due locked event (2 second wait) + ; Disable test if process-private globals are in use. + ; This test relies on getting HTTPERR from a JOB'ed process N RETURN,BODY,ARG,TIMEOUT,HTTPERR K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Temporaraily reset timeout value to a low number so unit tests don't take forever S TIMEOUT=^VPRCONFIG("timeout") S ^VPRCONFIG("timeout")=1 @@ -1034,6 +1036,8 @@ D SYNCSTAT(.BODY,"ZZUT") S ARG("id")="ZZUT" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) ; Begin storing a record + ; This uses ^TMP("ZZUT") for IPC to simulate multiple jobs storing at the same time. + ; This can't use process-private globals if available. L +^VPRSTATUSOD("ZZUT","allergy","urn:va:allergy:ZZUT:1001",20141031094923):$G(^VPRCONFIG("timeout"),5) E S ^TMP("ZZUT","LOCK")=1 Q S ^VPRSTATUSOD("ZZUT","allergy","urn:va:allergy:ZZUT:1001",20141031094923,"stored")=1 ; Attempt to store new metastamp while record is still in progress @@ -1041,8 +1045,8 @@ S ARG("id")="ZZUT" H 2 ; Ensure error codition exists D ASSERT("",$G(^TMP("ZZUT","LOCK")),"Record lock not acquired") - D ASSERT(500,$G(^TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","code")),"An HTTP 500 should exist") - D ASSERT(502,$G(^TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","errors",1,"reason")),"A 502 error should exist") + D ASSERT(500,$G(^||TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","code")),"An HTTP 500 should exist") + D ASSERT(502,$G(^||TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","errors",1,"reason")),"A 502 error should exist") ; Ensure locks are removed L -^VPRSTATUSOD("ZZUT","allergy","urn:va:allergy:ZZUT:1001",20141031094923) ; Ensure temp global is cleaned up @@ -1053,6 +1057,8 @@ D ASSERT(502,$G(^TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","errors",1, Q STORE S BODY(1)=" { ""stampTime"": ""20141031094922"",""sourceMetaStamp"": { ""ZZUT"": { ""stampTime"": ""20141031094922"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""itemMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094927"" } } } } } } }" + ; This uses ^TMP("ZZUT") for IPC to simulate multiple jobs storing at the same time. + ; This can't use process-private globals if available. S ^TMP("ZZUT","STOREJOB")=$J S ARG("id")="ZZUT" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) @@ -1060,7 +1066,7 @@ S ARG("id")="ZZUT" STAMPMRG ;; @TEST Merge of metaStamps N RETURN,BODY,ARG,TIMEOUT,HTTPERR K ^VPRSTATUSOD("ZZUT") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Setup initial metastamp D SYNCSTAT(.BODY,"ZZUT") S ARG("id")="ZZUT" @@ -1087,7 +1093,7 @@ D ASSERT(1,$D(^VPRSTATUSOD("ZZUT","vitals","urn:va:vitals:ZZUT:1002",20141031094 N DATA,ARG,ERR,OBJECT,RETURN,BODY,HTTPERR,LOC ; Store the data K ^VPRSTATUSOD("1234") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)="{""stampTime"":""20150717104657"",""sourceMetaStamp"":{""1234"":{""stampTime"":""20150717104657"",""domainMetaStamp"":{""asu-class"":{""domain"":""asu-class"",""stampTime"":""20150717104657"",""itemMetaStamp"":{""urn:va:asu-class:1234:100"":{""stampTime"":""20150717102913""}}}}}}}" S ARG("id")="1234" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) @@ -1128,7 +1134,7 @@ D ASSERT(0,$D(^VPRSTATUSOD(1234)),"CALL TO DEL^VPRJDSTATUS FAILED WITH AN ERROR" N DATA,ARG,ERR,OBJECT,RETURN,BODY,HTTPERR ; Store the data K ^VPRSTATUSOD("DBCA") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)="{""stampTime"": ""20141031094920"",""sourceMetaStamp"": {""DCBA"": {""stampTime"": ""20141031094920"",""domainMetaStamp"": {""doc-def"": {""domain"": ""doc-def"",""stampTime"": ""20141031094920"",""itemMetaStamp"": {""urn:va:doc-def:DCBA:1001"": {""stampTime"": ""20141031094920"" },""urn:va:doc-def:DCBA:1002"": {""stampTime"": ""20141031094920"",}}},""pt-select"": {""domain"": ""pt-select"",""stampTime"": ""20141031094920"",""itemMetaStamp"": {""urn:va:pt-select:DCBA:1001"": {""stampTime"": ""20141031094920"",},""urn:va:pt-select:DCBA:1002"": {""stampTime"": ""20141031094920"",}}}}}}}" S ARG("id")="DBCA" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) diff --git a/VPRJTSYSS.m b/VPRJTSYSS.m old mode 100755 new mode 100644 index 4962abb..1ac103e --- a/VPRJTSYSS.m +++ b/VPRJTSYSS.m @@ -3,7 +3,7 @@ ; STARTUP ; Run once before all tests K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K ^VPRPTJ("JPID","ZZUT;3") K ^VPRPTJ("JPID","ZZUT1;3") K ^VPRPTJ("JPID","1234V4321") @@ -16,7 +16,7 @@ Q SHUTDOWN ; Run once after all tests K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) K ^VPRPTJ("JPID","ZZUT;3") K ^VPRPTJ("JPID","ZZUT1;3") K ^VPRPTJ("JPID","1234V4321") @@ -77,49 +77,49 @@ N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"ZZUT;3","") S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$D(^VPRSTATUS(JPID,"ZZUT;3","ZZUT",20141031094921)),"A Patient Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(211,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") Q ERRORPID ;; @TEST Error code is set if no PID N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"","1234v4321") S ARG("id")="" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$D(^VPRSTATUS(JPID,"ZZUT;3","ZZUT",20141031094921)),"A Patient Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(227,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 227 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(227,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 227 error should exist") Q ERRORBPID ;; Error code is set if BAD PID N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"undefined","undefined") S ARG("id")="" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$D(^VPRSTATUS(JPID,"ZZUT;3","ZZUT",20141031094921)),"A Patient Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(211,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error should exist") Q ERRORCONF ;; @TEST Error code is set if ICN and PID conflict N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Set up Bad Patient IDs D SHUTDOWN D BADPATIDS @@ -129,8 +129,8 @@ D ASSERT(211,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 211 error s S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$D(^VPRSTATUS(JPID,"ZZUT;3","ZZUT",20141031094921)),"A Patient Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(223,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 223 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(223,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 223 error should exist") ; Reset Patient IDs D SHUTDOWN D PATIDS @@ -138,15 +138,15 @@ D ASSERT(223,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 223 error s ERRUNKPID ;; @TEST Error code is set if JPID is unknown N RETURN,BODY,ARG,HTTPERR K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Kill existing Patient ids and try to set a sync status D SHUTDOWN D SYNCSTAT(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) D ASSERT(0,$D(^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT",20141031094921)),"A Patient Sync Status exists and there should not be") - D ASSERT(404,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") - D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error should exist") + D ASSERT(404,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 404 should exist") + D ASSERT(224,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error should exist") ; Reset Patient IDs D SHUTDOWN D PATIDS @@ -155,7 +155,7 @@ D ASSERT(224,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 224 error s N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTAT(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) @@ -175,7 +175,7 @@ D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime does K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2370","ZZUT1;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2370","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; ZZUT D SYNCSTAT(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" @@ -207,77 +207,79 @@ D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime does N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTATNS(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$G(^VPRSTATUS(JPID,"ZZUT;3","ZZUT","stampTime"))=20141031094927,"A Patient Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") Q SETNODOMAIN ;; @TEST Error with no domain stampTime N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTATND(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$G(^VPRSTATUS(JPID,"ZZUT;3","ZZUT","stampTime"))=20141031094928,"A Patient Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") Q SETNOEVENT ;; @TEST Error with no event stampTime N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D SYNCSTATNE(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$G(^VPRSTATUS(JPID,"ZZUT;3","ZZUT","stampTime"))=20141031094929,"A Patient Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") Q SETNONNUM ;; @TEST Error with a non-numeric stampTime N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)=" { ""icn"": ""1234V4321"",""stampTime"": ""ASDF"",""sourceMetaStamp"": { ""ZZUT"": { ""pid"": ""ZZUT;3"",""localId"": ""3"",""stampTime"": ""20141031094921"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""eventMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""ASDF"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""eventMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": ""20141031094926"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927"" } } } } }" S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$G(^VPRSTATUS(JPID,"ZZUT;3","ZZUT","stampTime"))="ASDF","A Patient Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") Q SETSUBSEC ;; @TEST Error with a non-numeric stampTime N RETURN,BODY,ARG,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)=" { ""icn"": ""1234V4321"",""stampTime"": ""20141031094930"",""sourceMetaStamp"": { ""ZZUT"": { ""pid"": ""ZZUT;3"",""localId"": ""3"",""stampTime"": ""20141031094921"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""eventMetaStamp"": { ""urn:va:allergy:ZZUT:1001"": { ""stampTime"": ""20141031094923"" }, ""urn:va:allergy:ZZUT:1002"": { ""stampTime"": ""ASDF"" } } },""vitals"": { ""domain"": ""vitals"",""stampTime"": ""20141031094925"",""eventMetaStamp"": { ""urn:va:vitals:ZZUT:1001"": { ""stampTime"": ""20141031094926"" },""urn:va:vitals:ZZUT:1002"": { ""stampTime"": ""20141031094927.123"" } } } } }" S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) S JPID=$$JPID4PID^VPRJPR("ZZUT;3") D ASSERT(0,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime exists and it should not") D ASSERT(0,$G(^VPRSTATUS(JPID,"ZZUT;3","ZZUT","stampTime"))=20141031094930,"A Patient Sync Status exists and there should not be") - D ASSERT(400,$G(^TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") - D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") + D ASSERT(400,$G(^||TMP("HTTPERR",$J,1,"error","code")),"An HTTP 400 should exist") + D ASSERT(228,$G(^||TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error should exist") Q -SETERRLCK ;; @TEST Error due locked event (2 second wait) +SETERRLCK ;; TEST Error due locked event (2 second wait) + ; Disable test if process-private globals are in use. + ; This test relies on getting HTTPERR from a JOB'ed process N RETURN,BODY,ARG,TIMEOUT,HTTPERR K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2370","ZZUT1;3") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Temporaraily reset timeout value to a low number so unit tests don't take forever S TIMEOUT=^VPRCONFIG("timeout") S ^VPRCONFIG("timeout")=1 @@ -286,6 +288,8 @@ D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error s S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) ; Begin storing a record + ; This uses ^TMP("ZZUT") for IPC to simulate multiple jobs storing at the same time. + ; This can't use process-private globals if available. L +^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT","allergy","urn:va:allergy:ZZUT:3:1001",20141031094923):$G(^VPRCONFIG("timeout"),5) E S ^TMP("ZZUT","LOCK")=1 Q S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT","allergy","urn:va:allergy:ZZUT:3:1001",20141031094923,"stored")=1 ; Attempt to store new metastamp while record is still in progress @@ -293,25 +297,27 @@ D ASSERT(228,$G(^TMP("HTTPERR",$J,1,"error","errors",1,"reason")),"A 228 error s H 2 ; Ensure error codition exists D ASSERT("",$G(^TMP("ZZUT","LOCK")),"Record lock not acquired") - D ASSERT(500,$G(^TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","code")),"An HTTP 500 should exist") - D ASSERT(502,$G(^TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","errors",1,"reason")),"A 502 error should exist") + D ASSERT(500,$G(^||TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","code")),"An HTTP 500 should exist") + D ASSERT(502,$G(^||TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","errors",1,"reason")),"A 502 error should exist") ; Ensure locks are removed L -^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT","allergy","urn:va:allergy:ZZUT:3:1001",20141031094923) ; Ensure temp global is cleaned up - K ^TMP("HTTPERR",$J) - K ^TMP("HTTPERR",^TMP("ZZUT","STOREJOB")) - K ^TMP("VPRJERR",$J) + K ^||TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",^||TMP("ZZUT","STOREJOB")) + K ^||TMP("VPRJERR",$J) K ^TMP("ZZUT","LOCK") K ^TMP("ZZUT","STOREJOB") ; Reset timeout value back to what it was S ^VPRCONFIG("timeout")=TIMEOUT Q SETFLG - L +^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT","allergy","urn:va:allergy:ZZUT:3:1001",20141031094923):$G(^VPRCONFIG("timeout"),5) E S ^TMP("ZZUT","LOCK")=1 Q + L +^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT","allergy","urn:va:allergy:ZZUT:3:1001",20141031094923):$G(^VPRCONFIG("timeout"),5) E S ^||TMP("ZZUT","LOCK")=1 Q S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3","ZZUT","allergy","urn:va:allergy:ZZUT:3:1001",20141031094923,"stored")=1 Q STORE S BODY(1)=" { ""icn"": ""1234V4321"",""stampTime"": ""20141031094922"",""sourceMetaStamp"": { ""ZZUT"": { ""pid"": ""ZZUT;3"",""localId"": ""3"",""stampTime"": ""20141031094922"",""domainMetaStamp"": { ""allergy"": { ""domain"": ""allergy"",""stampTime"": ""20141031094922"",""eventMetaStamp"": { ""urn:va:allergy:ZZUT:3:1001"": { ""stampTime"": ""20141031094927"" } } } } } } }" + ; This uses ^TMP("ZZUT") for IPC to simulate multiple jobs storing at the same time. + ; This can't use process-private globals if available. S ^TMP("ZZUT","STOREJOB")=$J S ARG("id")="ZZUT;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) @@ -320,7 +326,7 @@ D ASSERT(502,$G(^TMP("HTTPERR",$G(^TMP("ZZUT","STOREJOB")),1,"error","errors",1, N RETURN,BODY,ARG,TIMEOUT,HTTPERR,JPID K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","ZZUT;3") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) ; Setup initial metastamp D SYNCSTAT(.BODY,"ZZUT;3","1234V4321") S ARG("id")="ZZUT;3" @@ -353,7 +359,7 @@ D ASSERT(1,$D(^VPRMETA("JPID",JPID,"lastAccessTime")),"Sync lastAccessTime does ; Store the data K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","1234") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)="{""icn"":""1234V4321"",""stampTime"":""20141031094921"",""sourceMetaStamp"":{""1234"":{""pid"":""1234;3"",""localId"":""3"",""stampTime"":""20141031094921"",""domainMetaStamp"":{""allergy"":{""domain"":""allergy"",""stampTime"":""20141031094922"",""eventMetaStamp"":{""urn:va:allergy:1234:1001"":{""stampTime"":""20141031094923""}}}}}}}" S ARG("id")="1234;3" S RETURN=$$SET^VPRJPSTATUS(.ARG,.BODY) @@ -394,7 +400,7 @@ D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","""1234","syncCompleteAsOf" ; Store the data K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","1234") K ^VPRMETA("JPID","52833885-af7c-4899-90be-b3a6630b2369","lastAccessTime") - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) S BODY(1)="{""stampTime"":""20141031094921"",""sourceMetaStamp"":{""1234"":{""stampTime"":""20141031094921"",""domainMetaStamp"":{""allergy"":{""domain"":""allergy"",""stampTime"":""20141031094922"",""itemMetaStamp"":{""urn:va:allergy:1234:1001"":{""stampTime"":""20141031094923""}}}}}}}" S ARG("id")="1234" S RETURN=$$SET^VPRJDSTATUS(.ARG,.BODY) diff --git a/VPRJTSYST.m b/VPRJTSYST.m old mode 100755 new mode 100644 index 0bc347c..4675eb6 --- a/VPRJTSYST.m +++ b/VPRJTSYST.m @@ -18,63 +18,63 @@ ; BLANK ; basic sync status K ^VPRSTATUS - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","stampTime")=20141031094920 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","stampTime")=20141031094920 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920)="" Q ; BLANK2 ; basic sync status K ^VPRSTATUS - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","stampTime")=20141031094920 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","stampTime")=20141031094930 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy",20141031094933)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094931)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094931)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals",20141031094933)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094932)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094932)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","stampTime")=20141031094920 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","stampTime")=20141031094930 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094933)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094931)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094931)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals",20141031094933)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094932)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094932)="" Q ; BLANK2DIFF ; basic sync status K ^VPRSTATUS - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","stampTime")=20141031094920 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","stampTime")=20141031094930 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy",20141031094933)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy","urn:va:allergy:C877:3:1001",20141031094931)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy","urn:va:allergy:C877:3:1002",20141031094931)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals",20141031094933)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals","urn:va:vitals:C877:3:1001",20141031094932)="" - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals","urn:va:vitals:C877:3:1002",20141031094932)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","stampTime")=20141031094920 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","stampTime")=20141031094930 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094933)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094931)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094931)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals",20141031094933)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094932)="" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094932)="" Q ; PATIDS ; Setup patient identifiers S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","9E7A;3")="" - S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","C877;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" + S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","SITE;3")="" S ^VPRPTJ("JPID","52833885-af7c-4899-90be-b3a6630b2369","1234V4321")="" - S ^VPRPTJ("JPID","9E7A;3")="52833885-af7c-4899-90be-b3a6630b2369" - S ^VPRPTJ("JPID","C877;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" + S ^VPRPTJ("JPID","SITE;3")="52833885-af7c-4899-90be-b3a6630b2369" S ^VPRPTJ("JPID","1234V4321")="52833885-af7c-4899-90be-b3a6630b2369" Q GETBEFORE ;; @TEST Get Patient Sync Status before metastamp stored N DATA,ARG,ERR,OBJECT,HTTPERR - S ARG("id")="9E7A;3" + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -85,7 +85,7 @@ D ASSERT(0,$D(ERR),"ERROR DECODING JSON") D ASSERT(0,$D(OBJECT("inProgress")),"Sync status is not inProgress") D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") ; Try again with an event stored - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test @@ -99,7 +99,7 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") GETINITIAL ;; @TEST Get Initial Patient Sync Status N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK - S ARG("id")="9E7A;3" + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -114,36 +114,36 @@ D ASSERT("1234V4321",$G(OBJECT("inProgress","icn"))) ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") - D ASSERT("9E7A;3",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","pid")),"pid is incorrect") - D ASSERT(3,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","localId")),"localId is incorrect") - D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","stampTime")),"source stampTime doesn't exist") + D ASSERT("SITE;3",$G(OBJECT("inProgress","sourceMetaStamp","SITE","pid")),"pid is incorrect") + D ASSERT(3,$G(OBJECT("inProgress","sourceMetaStamp","SITE","localId")),"localId is incorrect") + D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","SITE","stampTime")),"source stampTime doesn't exist") ; ensure allergy domain and event stamps exist correctly - D ASSERT("allergy",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","domain")),"allergy domain doesn't exist") - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stampTime")),"Allergy 9E7A:3:1001 stampTime doesn't exist") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 shouldn't be stored") - D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stampTime")),"Allergy 9E7A:3:1002 stampTime doesn't exist") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 shouldn't be stored") + D ASSERT("allergy",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","domain")),"allergy domain doesn't exist") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stampTime")),"Allergy SITE:3:1001 stampTime doesn't exist") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 shouldn't be stored") + D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stampTime")),"Allergy SITE:3:1002 stampTime doesn't exist") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 shouldn't be stored") ; ensure vitals domain and event stamps exist correctly - D ASSERT("vitals",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","domain")),"vitals domain doesn't exist") - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stampTime")),"Vital 9E7A:3:1001 stampTime doesn't exist") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 shouldn't be stored") - D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stampTime")),"Vital 9E7A:3:1002 stampTime doesn't exist") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 shouldn't be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("vitals",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","domain")),"vitals domain doesn't exist") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stampTime")),"Vital SITE:3:1001 stampTime doesn't exist") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 shouldn't be stored") + D ASSERT(20141031094920,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stampTime")),"Vital SITE:3:1002 stampTime doesn't exist") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 shouldn't be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") K @DATA Q GETLASTVITAL ;; @TEST Get Patient Sync Status - Last Vital Stored N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -156,27 +156,27 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"stored is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"stored is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") ; Last Vital should be stored - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") K @DATA Q GETLASTALLERGY ;; @TEST Get Patient Sync Status - Last Allergy Stored N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -189,28 +189,28 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"stored is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"stored is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"stored is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"stored is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored") ; Last Allergy should be stored - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") K @DATA Q GETLASTALLERGYVITAL ;; @TEST Get Patient Sync Status - Last Vital & Allergy Stored N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -223,28 +223,28 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"stored is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"stored is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"stored is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(1,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"stored is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") ; Last Allergy & Vital should be stored - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") K @DATA Q GETALLERGY ;; @TEST Get Patient Sync Status - Both Allergies Stored. Test complete flag being set N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -257,27 +257,27 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") K @DATA Q GETVITAL ;; @TEST Get Patient Sync Status - Both Vitals Stored. Test complete flag being set N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -290,29 +290,29 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") K @DATA Q GETBOTH ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored. Test SyncComplete flag being set N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -325,19 +325,19 @@ D ASSERT(10,$D(OBJECT("completedStamp")),"Sync status is not completed") D ASSERT(0,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress exists, but should not") D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored") - D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should exist") - D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") K @DATA Q GET2SAMESOURCE ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored. Test SyncComplete flag being set for 2 metaStamps for the same source @@ -345,11 +345,11 @@ D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf D BLANK2 ; Setup to make sure the old object doesn't appear ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -362,26 +362,26 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not completed") D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored") ; Vitals domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") ; Setup to make sure the new object completes K ARG,@DATA,OBJECT,ERR ; Set complete flags - allergy uses incorrect times - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094932,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094932,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -394,27 +394,27 @@ D ASSERT(10,$D(OBJECT("completedStamp")),"Sync status is not completed") D ASSERT(0,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should not be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored") - D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should exist") - D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") ; Setup to make sure the new object completes K ARG,@DATA,OBJECT,ERR ; Set complete flags - allergy uses correct times - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094931,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094931,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094931,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094931,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -427,26 +427,26 @@ D ASSERT(10,$D(OBJECT("completedStamp")),"Sync status is completed") D ASSERT(0,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress exists, but should not") D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored") - D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should exist") - D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") K @DATA Q GET2DIFFSOURCE ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored. Test SyncComplete flag being set for 2 metaStamps for different sources N DATA,ARG,ERR,OBJECT,HTTPERR D BLANK2DIFF ; Setup to make sure both objects are inProgress - S ARG("id")="9E7A;3" + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") @@ -458,150 +458,150 @@ D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is completed") ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") D ASSERT(0,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp exists, but should not") - ; 9E7A + ; SITE ; Source should exist - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","9E7A")),"Source 9E7A should exist") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE")),"Source SITE should exist") ; Allergy domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should not exist") - ; C877 + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + ; SITE ; Source should exist - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","C877")),"Source C877 should exist") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE")),"Source SITE should exist") ; Allergy domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1001","stored")),"Allergy C877:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1002","stored")),"Allergy C877:3:1002 should not be stored") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored") ; Vitals domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1001","stored")),"Vital C877:3:1001 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1002","stored")),"Vital C877:3:1002 should not be stored") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") ; Setup to make sure one source is complete K ARG,@DATA,OBJECT,ERR ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") - ; 9E7A + ; SITE ; this Sync Status should now be completed ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; Source should exist - D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A")),"Source 9E7A should exist and be complete (9E7A)") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE")),"Source SITE should exist and be complete (SITE)") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (9E7A)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored (9E7A)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored (9E7A)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (SITE)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored (SITE)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored (SITE)") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (9E7A)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored (9E7A)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored (9E7A)") - D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should exist") - D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") - ; C877 + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (SITE)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored (SITE)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored (SITE)") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") + ; SITE ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") ; Source should exist - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","C877")),"Source C877 should exist and not be complete (9E7A)") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE")),"Source SITE should exist and not be complete (SITE)") ; Allergy domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete (9E7A)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1001","stored")),"Allergy C877:3:1001 should not be stored (9E7A)") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1002","stored")),"Allergy C877:3:1002 should not be stored (9E7A)") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete (SITE)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored (SITE)") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored (SITE)") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (9E7A)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1001","stored")),"Vital C877:3:1001 should not be stored (9E7A)") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1002","stored")),"Vital C877:3:1002 should not be stored (9E7A)") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","syncCompleteAsOf")),"syncCompleteAsOf should not exist") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (SITE)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored (SITE)") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored (SITE)") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should not exist") ; Setup to make sure both sources are complete K ARG,@DATA,OBJECT,ERR - ; Set complete flags C877 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals","urn:va:vitals:C877:3:1001",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals","urn:va:vitals:C877:3:1002",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy","urn:va:allergy:C877:3:1001",20141031094931,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy","urn:va:allergy:C877:3:1002",20141031094931,"stored")=1 - S ARG("id")="9E7A;3" + ; Set complete flags SITE + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094931,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094931,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") - ; 9E7A + ; SITE ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; this Sync Status should now be completed ; Source should exist - D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A")),"Source 9E7A should exist and be complete (All)") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE")),"Source SITE should exist and be complete (All)") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored (All)") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (All)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored (All)") - D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf")),"syncCompleteAsOf should exist") - D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") - ; C877 + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (All)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored (All)") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") + ; SITE ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; Source should exist - D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","C877")),"Source C877 should exist and be complete (All)") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE")),"Source SITE should exist and be complete (All)") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1001","stored")),"Allergy C877:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1002","stored")),"Allergy C877:3:1002 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored (All)") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (All)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1001","stored")),"Vital C877:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1002","stored")),"Vital C877:3:1002 should be stored (All)") - D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","C877","syncCompleteAsOf")),"syncCompleteAsOf should exist") - D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","C877","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (All)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored (All)") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf")),"syncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))?14N,"syncCompleteAsOf isn't 14 digits") K @DATA Q ; GETFILTER ;; @TEST Get Patient Sync Status with filters N DATA,ARG,ERR,OBJECT,HTTPERR - K ^TMP("HTTPERR",$J) + K ^||TMP("HTTPERR",$J) D BLANK ; - S ARG("id")="9E7A;3" + S ARG("id")="SITE;3" ; Test that domain can be filtered when not in detailed mode S ARG("filter")="eq(""domain"",""allergy"")" D GET^VPRJPSTATUS(.DATA,.ARG) @@ -612,8 +612,8 @@ S ARG("filter")="eq(""domain"",""allergy"")" ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Test filters while inProgress - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") - D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals")),"Vitals domain exists and it should not") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals")),"Vitals domain exists and it should not") ; K DATA,OBJECT S ARG("detailed")="true" @@ -626,14 +626,14 @@ S ARG("filter")="eq(""domain"",""vitals"")" ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; In detailed mode, domain filtering only filters eventMetaStamp, not domainMetaStamp - D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain exists and it should not") - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain does not exist and it should") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain exists and it should not") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain does not exist and it should") ; K DATA,OBJECT S ARG("detailed")="true" ; Test that filter by uid works - S ^VPRSTATUS("9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ARG("filter")="eq(""uid"",""urn:va:vitals:9E7A:3:1001"")" + S ^VPRSTATUS("SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ARG("filter")="eq(""uid"",""urn:va:vitals:SITE:3:1001"")" D GET^VPRJPSTATUS(.DATA,.ARG) ; If data is blank force error and quit I $D(DATA)=0 D ASSERT(0,1,"Return variable undefined") Q @@ -641,13 +641,13 @@ S ARG("filter")="eq(""uid"",""urn:va:vitals:9E7A:3:1001"")" ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; In detailed mode, domain filtering only filters eventMetaStamp, not domainMetaStamp - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain does not exist and it should") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain does not exist and it should") ; ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 ; Test that syncCompleted K DATA,OBJECT K ARG("detailed") @@ -660,8 +660,8 @@ S ARG("filter")="exists(""syncCompleted"")" ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") ; Test filters while in completedStamp - D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") - D ASSERT(0,$D(OBJECT("completedStampe","sourceMetaStamp","9E7A","domainMetaStamp","vitals")),"Vitals domain exists and it should not") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") + D ASSERT(0,$D(OBJECT("completedStampe","sourceMetaStamp","SITE","domainMetaStamp","vitals")),"Vitals domain exists and it should not") ; K DATA,OBJECT S ARG("detailed")="true" @@ -673,8 +673,8 @@ S ARG("filter")="eq(""domain"",""allergy""),exists(""stored"")" D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") - D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain exists and it should not") - D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain does not exist and it should") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain exists and it should not") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain does not exist and it should") Q ; GET2NODOMAINSTAMP ;; @TEST Get Patient Sync Status - Domain syncComplete only when domain stamp exists @@ -682,105 +682,1149 @@ D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp" D BLANK2DIFF ; ; Remove domainstamp for the first site - K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy",20141031094920) + K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094920) ; Set complete flags - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","vitals","urn:va:vitals:9E7A:3:1002",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1001",20141031094920,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy","urn:va:allergy:9E7A:3:1002",20141031094920,"stored")=1 - S ARG("id")="9E7A;3" + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") - ; 9E7A + ; SITE ; this Sync Status should be inProgress since a domainStamp for allergies doesn't exist ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; Source should exist - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","9E7A")),"Source 9E7A should exist and be complete (9E7A)") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE")),"Source SITE should exist and be complete (SITE)") ; Allergy domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (9E7A)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored (9E7A)") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored (9E7A)") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (SITE)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored (SITE)") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored (SITE)") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (9E7A)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored (9E7A)") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored (9E7A)") - ; C877 + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (SITE)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored (SITE)") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored (SITE)") + ; SITE ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime inProgress does not exist, but should") ; Source should exist - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","C877")),"Source C877 should exist and not be complete (9E7A)") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE")),"Source SITE should exist and not be complete (SITE)") ; Allergy domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete (9E7A)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1001","stored")),"Allergy C877:3:1001 should not be stored (9E7A)") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1002","stored")),"Allergy C877:3:1002 should not be stored (9E7A)") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete (SITE)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should not be stored (SITE)") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should not be stored (SITE)") ; Vitals domain should not be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (9E7A)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1001","stored")),"Vital C877:3:1001 should not be stored (9E7A)") - D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1002","stored")),"Vital C877:3:1002 should not be stored (9E7A)") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (SITE)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(0,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should not be stored (SITE)") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should not be stored (SITE)") ; Setup to make sure both sources are complete K ARG,@DATA,OBJECT,ERR - ; Set the domain metastamp for 9E7A - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","9E7A;3","9E7A","allergy",20141031094920)="" - ; Kill the domain metastamp for C877 - K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals",20141031094933) - ; Set complete flags C877 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals","urn:va:vitals:C877:3:1001",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","vitals","urn:va:vitals:C877:3:1002",20141031094932,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy","urn:va:allergy:C877:3:1001",20141031094931,"stored")=1 - S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","C877;3","C877","allergy","urn:va:allergy:C877:3:1002",20141031094931,"stored")=1 - S ARG("id")="9E7A;3" + ; Set the domain metastamp for SITE + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy",20141031094920)="" + ; Kill the domain metastamp for SITE + K ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals",20141031094933) + ; Set complete flags SITE + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094932,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094931,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094931,"stored")=1 + S ARG("id")="SITE;3" S ARG("detailed")="true" D GET^VPRJPSTATUS(.DATA,.ARG) D DECODE^VPRJSON(DATA,"OBJECT","ERR") ; If we can't decode the JSON Fail the test D ASSERT(0,$D(ERR),"ERROR DECODING JSON") - ; 9E7A + ; SITE ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("completedStamp","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; this Sync Status should now be completed ; Source should exist - D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","9E7A")),"Source 9E7A should exist and be complete (All)") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE")),"Source SITE should exist and be complete (All)") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1001","stored")),"Allergy 9E7A:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:9E7A:3:1002","stored")),"Allergy 9E7A:3:1002 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored (All)") ; Vitals domain should be complete - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (All)") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1001","stored")),"Vital 9E7A:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","9E7A","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:9E7A:3:1002","stored")),"Vital 9E7A:3:1002 should be stored (All)") - ; C877 + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete (All)") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored (All)") + ; SITE ; Since the sync status is mocked, lastAccessTime won't be set but should exist D ASSERT(1,$D(OBJECT("inProgress","lastAccessTime"))#2,"Sync lastAccessTime completedStamp does not exist, but should") ; Source should exist - D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","C877")),"Source C877 should exist and be complete (All)") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE")),"Source SITE should exist and be complete (All)") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","stored")),"Allergy SITE:3:1002 should be stored (All)") + ; Vitals domain should be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (All)") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") + D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","stored")),"Vital SITE:3:1001 should be stored (All)") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vital SITE:3:1002 should be stored (All)") + K @DATA + Q + ; + ; SOLR stored tests + ; +GETBEFORESOLR ;; @TEST Get Patient Sync Status before metastamp stored (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + ; + ; Clean out all old data + K ^VPRSTATUS + K ^VPRPTJ("JPID") + K ^VPRMETA("JPID") + D PATIDS + ; + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; since solrSyncComplete is nested under inProgress or completedStamp, the code below will catch + ; it without an explicit test + D ASSERT(0,$D(OBJECT("inProgress")),"inProgress Sync Status exists") + D ASSERT(0,$D(OBJECT("completedStamp")),"completedStamp Sync Status exists") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncComplete exists when it shouldn't") + ; Try again with an event stored + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; since solrSyncComplete is nested under inProgress or completedStamp, the code below will catch + ; it without an explicit test + D ASSERT(0,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETINITIALSOLR ;; @TEST Get Initial Patient Sync Status (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncComplete exists when it shouldn't") + ; ensure allergy domain and event stamps exist correctly + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 shouldn't be solrStored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 shouldn't be solrStored") + ; ensure vitals domain and event stamps exist correctly + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 shouldn't be solrStored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 shouldn't be solrStored") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETLASTVITALSOLR ;; @TEST Get Patient Sync Status - Last Vital Stored (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncComplete exists when it shouldn't") + ; Allergy domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 should not be solrStored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 should not be solrStored") + ; Vitals domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 should not be solrStored") + ; Last Vital should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 should be solrStored") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETLASTALLERGYSOLR ;; @TEST Get Patient Sync Status - Last Allergy Stored (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrStored")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't be") + ; Allergy domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 should not be stored") + ; Vitals domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 should not be solrStored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 should not be solrStored") + ; Last Allergy should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 should be solrStored") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETLASTALLERGYVITALSOLR ;; @TEST Get Patient Sync Status - Last Vital & Allergy Stored (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't be") + ; Allergy domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 should not be solrStored") + ; Vitals domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 should not be solrStored") + ; Last Allergy & Vital should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 should be solrStored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 should be solrStored") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETALLERGYSOLR ;; @TEST Get Patient Sync Status - Both Allergies Stored. Test complete flag being set (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrStored")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't be") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should be solrSyncComplete") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 should be solrStored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 should be solrStored") + ; Vitals domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncComplete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 should not be solrStored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 should not be solrStored") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETVITALSOLR ;; @TEST Get Patient Sync Status - Both Vitals Stored. Test complete flag being set (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncComplete exists when it shouldn't") + ; Allergy domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","syncCompleted")),"allergy domain should not be complete") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 should not be solrStored") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 should not be solrStored") + ; Vitals domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","syncCompleted")),"vitals domain should be complete") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 should be solrStored") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 should be solrStored") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETBOTHSOLR ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored. Test SyncComplete flag being set (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrStored")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be completed + D ASSERT(0,$D(OBJECT("inProgress")),"Sync status is not completed") + D ASSERT(10,$D(OBJECT("completedStamp")),"Sync status is not completed") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncComplete doesn't exist when it should") ; Allergy domain should be complete - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","syncCompleted")),"allergy domain should be complete (All)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1001","stored")),"Allergy C877:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:C877:3:1002","stored")),"Allergy C877:3:1002 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should be solrSyncComplete") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy SITE:3:1001 should be solrStored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrStored")),"Allergy SITE:3:1002 should be solrStored") ; Vitals domain should be complete - D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","syncCompleted")),"vitals domain should not be complete (All)") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventCount")),"eventCount is incorrect") - D ASSERT(2,$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","storedCount")),"storedCount is incorrect") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1001","stored")),"Vital C877:3:1001 should be stored (All)") - D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","C877","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:C877:3:1002","stored")),"Vital C877:3:1002 should be stored (All)") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should be solrSyncComplete") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 should be solrStored") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 should be solrStored") + D ASSERT(1,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf"))?14N,"solrSyncCompleteAsOf isn't 14 digits") + K @DATA + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q +GETFILTERSOLR ;; @TEST Get Patient Sync Status with filters (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + N SOLR + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + K ^TMP("HTTPERR",$J) + D BLANK + ; + S ARG("id")="SITE;3" + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + ; Test that syncCompleted + K DATA,OBJECT + K ARG("detailed") + ; Test that sync has been complete when not in detailed mode + S ARG("filter")="exists(""solrSyncCompleted"")" + D GET^VPRJPSTATUS(.DATA,.ARG) + ; If data is blank force error and quit + I $D(DATA)=0 D ASSERT(0,1,"Return variable is blank") Q + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Test filters while in completedStamp + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals")),"Vitals domain does not exist and it should") + ; + K DATA,OBJECT + S ARG("detailed")="true" + ; Test that domain has been stored when in detailed mode + S ARG("filter")="eq(""domain"",""allergy""),exists(""solrStored"")" + D GET^VPRJPSTATUS(.DATA,.ARG) + ; If data is blank force error and quit + I $D(DATA)=0 D ASSERT(0,1,"Return variable is blank") Q + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain does not exist and it should") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain exists and it should not") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf isn't a domain and it should not exist") + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + Q + ; +GETSOLREXCEPTIONS ;; @TEST Get Patient Simple Sync Status with SOLR domain exceptions + N DATA,ARG,ERR,OBJECT,HTTPERR + ; save off SOLR configuration + N SOLR,DOMAINEXCEPTIONS + S SOLR=$G(^VPRCONFIG("sync","status","solr")) + M DOMAINEXCEPTIONS=^VPRCONFIG("sync","status","solr","domainExceptions") + K ^VPRCONFIG("sync","status","solr","domainExceptions") + ; Enable SOLR Sync Status reporting + S ^VPRCONFIG("sync","status","solr")=1 + D BLANK + S ARG("id")="SITE;3" + ; + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + ; + S ARG("detailed")="false" + D GET^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"Allergy SOLR data should be false") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"Vitals SOLR data should be false") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should not exist") + ; + ; Try again with the allergy domain added to the exceptions list + S ^VPRCONFIG("sync","status","solr","domainExceptions","allergy")="" + ; + D GET^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Ensure that the JSON matches what we expect + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"Allergy SOLR data should be true") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"Vitals SOLR data should be false") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should not exist") + ; + ; Try again with the vitals domain also added to the exceptions list + S ^VPRCONFIG("sync","status","solr","domainExceptions","vitals")="" + ; + D GET^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"Allergy SOLR data should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"Vitals SOLR data should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted should be true") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))=$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should match syncCompleteAsOf") + ; + ; Remove the SOLR domain exceptions and re-run with detail + K ^VPRCONFIG("sync","status","solr","domainExceptions","allergy") + K ^VPRCONFIG("sync","status","solr","domainExceptions","vitals") + ; + H 1 ; ensure that solrSyncCompleteAsOf is an earlier timestamp than syncCompleteAsOf during failed SOLR syncs + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"Allergy SOLR data should be false") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"Vitals SOLR data should be false") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy stored flag should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vitals stored flag should be true") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy solrStored flag should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vitals solrStored flag should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted should not exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))>$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should be an earlier date than syncCompleteAsOf") + ; + ; Try again with the allergy domain added to the exceptions list + S ^VPRCONFIG("sync","status","solr","domainExceptions","allergy")="" + ; + D GET^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Ensure that the JSON matches what we expect + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"Allergy SOLR data should be true") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"Vitals SOLR data should be false") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy stored flag should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vitals stored flag should be true") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy solrStored flag should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vitals solrStored flag should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted should not exist") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))>$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should be an earlier date than syncCompleteAsOf") + ; + ; Try again with the vitals domain also added to the exceptions list + S ^VPRCONFIG("sync","status","solr","domainExceptions","vitals")="" + ; + D GET^VPRJPSTATUS(.DATA,.ARG) + I $D(DATA) K OBJECT D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; + ; Ensure that the JSON matches what we expect + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"Allergy SOLR data should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"Vitals SOLR data should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","stored")),"Allergy stored flag should be true") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","stored")),"Vitals stored flag should be true") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrStored")),"Allergy solrStored flag should not exist") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vitals solrStored flag should not exist") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted should be true") + D ASSERT(1,$G(OBJECT("completedStamp","sourceMetaStamp","SITE","syncCompleteAsOf"))=$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleteAsOf")),"solrSyncCompleteAsOf should match syncCompleteAsOf") + ; + I $D(DATA) K @DATA + K ^VPRPTJ("JPID") + D PATIDS + ; Reset SOLR configuration + S:(SOLR'="") ^VPRCONFIG("sync","status","solr")=SOLR + K ^VPRCONFIG("sync","status","solr","domainExceptions") + M ^VPRCONFIG("sync","status","solr","domainExceptions")=DOMAINEXCEPTIONS + Q + ; + ; SOLR ERROR tests + ; +GETBEFORESOLRERROR ;; @TEST Get Patient Sync Status before metastamp stored (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + ; Clean out all old data + K ^VPRSTATUS + K ^VPRPTJ("JPID") + K ^VPRMETA("JPID") + D PATIDS + ; + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; since solrSyncComplete is nested under inProgress or completedStamp, the code below will catch + ; it without an explicit test + D ASSERT(0,$D(OBJECT("inProgress")),"inProgress Sync Status exists") + D ASSERT(0,$D(OBJECT("completedStamp")),"completedStamp Sync Status exists") + ; Try again with a solr event in error + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; This data won't exist since we haven't received an initial metastamp yet. + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError"))) + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError"))) + K @DATA + Q +GETINITIALSOLRERROR ;; @TEST Get Initial Patient Sync Status (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSolrError")),"hasSolrError set when it shouldn't") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted set when it shouldn't") + ; ensure allergy domain and event stamps exist correctly + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should not have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 shouldn't have solrError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 shouldn't have solrError") + ; ensure vitals domain and event stamps exist correctly + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should not have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrStored")),"Vital SITE:3:1001 shouldn't have solrError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrStored")),"Vital SITE:3:1002 shouldn't have solrError") K @DATA Q +GETLASTVITALSOLRERROR ;; @TEST Get Patient Sync Status - Last Vital Stored (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should not have solrError + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should not have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should not have solrError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should not have solrError") + ; Vitals domain should have solrError + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should not have solrError") + ; Last Vital should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should have solrError") + K @DATA + Q +GETLASTALLERGYSOLRERROR ;; @TEST Get Patient Sync Status - Last Allergy Stored (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should have solrError + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should not have solrError") + ; Vitals domain should not have solrError + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should not have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should not have solrError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should not have solrError") + ; Last Allergy should have solrError + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should have solrError") + K @DATA + Q +GETLASTALLERGYVITALSOLRERROR ;; @TEST Get Patient Sync Status - Last Vital & Allergy Stored (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should not be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should not have solrError") + ; Vitals domain should not be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should not have solrError") + ; Last Allergy & Vital should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should have solrError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should have solrError") + K @DATA + Q +GETALLERGYSOLRERROR ;; @TEST Get Patient Sync Status - Both Allergies Stored. Test complete flag being set (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should have solrError") + ; Vitals domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should not have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should not have solrError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should not have solrError") + K @DATA + Q +GETVITALSOLRERROR ;; @TEST Get Patient Sync Status - Both Vitals Stored. Test complete flag being set (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should not have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should not have solrError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should not have solrError") + ; Vitals domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should have solrError") + K @DATA + Q +GETBOTHSOLRERROR ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored. Test SyncComplete flag being set (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be completed + D ASSERT(0,$D(OBJECT("inProgress")),"Sync status is not completed") + D ASSERT(10,$D(OBJECT("completedStamp")),"Sync status is not completed") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should have solrError") + ; Vitals domain should be complete + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should have solrError") + K @DATA + Q +GETBOTHSOLRERRORSTORED ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored and Solr Stored. Test SyncComplete flag being set (SOLR ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrStored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be completed + D ASSERT(0,$D(OBJECT("inProgress")),"Sync status is not completed") + D ASSERT(10,$D(OBJECT("completedStamp")),"Sync status is not completed") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","hasSolrError")),"doesn't have hasSolrError when it should") + D ASSERT("",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","solrSyncCompleted")),"solrSyncCompleted when it shouldn't") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSolrError")),"allergy domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","solrSyncCompleted")),"allergy domain should not be solrSyncCompleted") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should have solrError") + ; Vitals domain should be complete + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSolrError")),"vitals domain should have hasSolrError") + D ASSERT("false",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","solrSyncCompleted")),"vitals domain should not be solrSyncCompleted") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","solrError")),"Vital SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","solrError")),"Vital SITE:3:1002 should have solrError") + K @DATA + Q +GETFILTERSOLRERROR ;; @TEST Get Patient Sync Status with filters (SOLR) + N DATA,ARG,ERR,OBJECT,HTTPERR + K ^TMP("HTTPERR",$J) + D BLANK + ; + S ARG("id")="SITE;3" + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"solrError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"solrError")=1 + ; Test that syncCompleted + K DATA,OBJECT + K ARG("detailed") + ; Test that sync has been complete when not in detailed mode + S ARG("filter")="exists(""hasSolrError"")" + D GET^VPRJPSTATUS(.DATA,.ARG) + ; If data is blank force error and quit + I $D(DATA)=0 D ASSERT(0,1,"Return variable is blank") Q + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Test filters while in completedStamp + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals")),"Vitals domain does not exist and it should") + ; + K DATA,OBJECT + S ARG("detailed")="true" + ; Test that domain has been stored when in detailed mode + S ARG("filter")="eq(""domain"",""allergy""),exists(""solrError"")" + D GET^VPRJPSTATUS(.DATA,.ARG) + ; If data is blank force error and quit + I $D(DATA)=0 D ASSERT(0,1,"Return variable is blank") Q + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + D ASSERT(10,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain does not exist and it should") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","solrError")),"Allergy SITE:3:1001 should have solrError") + D ASSERT("true",$G(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","solrError")),"Allergy SITE:3:1002 should have solrError") + D ASSERT(0,$D(OBJECT("completedStamp","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain exists and it should not") + Q + ; + ; SYNC ERROR tests + ; +GETBEFORESYNCERROR ;; @TEST Get Patient Sync Status before metastamp stored (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + ; Clean out all old data + K ^VPRSTATUS + K ^VPRPTJ("JPID") + K ^VPRMETA("JPID") + D PATIDS + ; + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; since syncSyncComplete is nested under inProgress or completedStamp, the code below will catch + ; it without an explicit test + D ASSERT(0,$D(OBJECT("inProgress")),"inProgress Sync Status exists") + D ASSERT(0,$D(OBJECT("completedStamp")),"completedStamp Sync Status exists") + ; Try again with a sync event in error + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")=1 + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; This data won't exist since we haven't received an initial metastamp yet. + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError"))) + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError"))) + K @DATA + Q +GETINITIALSYNCERROR ;; @TEST Get Initial Patient Sync Status (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"hasSyncError set when it shouldn't") + ; ensure allergy domain and event stamps exist correctly + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should not have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 shouldn't have syncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 shouldn't have syncError") + ; ensure vitals domain and event stamps exist correctly + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should not have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncStored")),"Vital SITE:3:1001 shouldn't have syncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncStored")),"Vital SITE:3:1002 shouldn't have syncError") + K @DATA + Q +GETLASTVITALSYNCERROR ;; @TEST Get Patient Sync Status - Last Vital Stored (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"doesn't have hasSyncError when it should") + ; Allergy domain should not have syncError + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should not have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should not have syncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should not have syncError") + ; Vitals domain should have syncError + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncError")),"Vital SITE:3:1001 should not have syncError") + ; Last Vital should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError")),"Vital SITE:3:1002 should have syncError") + K @DATA + Q +GETLASTALLERGYSYNCERROR ;; @TEST Get Patient Sync Status - Last Allergy Stored (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"syncError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"doesn't have hasSyncError when it should") + ; Allergy domain should have syncError + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should not have syncError") + ; Vitals domain should not have syncError + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should not have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncError")),"Vital SITE:3:1001 should not have syncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError")),"Vital SITE:3:1002 should not have syncError") + ; Last Allergy should have syncError + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should have syncError") + K @DATA + Q +GETLASTALLERGYVITALSYNCERROR ;; @TEST Get Patient Sync Status - Last Vital & Allergy Stored (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"doesn't have hasSyncError when it should") + ; Allergy domain should not be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should not have syncError") + ; Vitals domain should not be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncError")),"Vital SITE:3:1001 should not have syncError") + ; Last Allergy & Vital should be stored + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should have syncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError")),"Vital SITE:3:1002 should have syncError") + K @DATA + Q +GETALLERGYSYNCERROR ;; @TEST Get Patient Sync Status - Both Allergies Stored. Test complete flag being set (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"syncError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"doesn't have hasSyncError when it should") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should have hasSyncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should have syncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should have syncError") + ; Vitals domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should not have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncError")),"Vital SITE:3:1001 should not have syncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError")),"Vital SITE:3:1002 should not have syncError") + K @DATA + Q +GETVITALSYNCERROR ;; @TEST Get Patient Sync Status - Both Vitals Stored. Test complete flag being set (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be in progress + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not inProgress") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is not inProgress") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"doesn't have hasSyncError when it should") + ; Allergy domain should not be complete + D ASSERT("false",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should not have hasSyncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should not have syncError") + D ASSERT("",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should not have syncError") + ; Vitals domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should have hasSyncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncError")),"Vital SITE:3:1001 should have syncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError")),"Vital SITE:3:1002 should have syncError") + K @DATA + Q +GETBOTHSYNCERROR ;; @TEST Get Patient Sync Status - Allergy and Vitals Stored. Test SyncComplete flag being set (SYNC ERROR) + N DATA,ARG,ERR,OBJECT,HTTPERR + D BLANK + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"syncError")=1 + S ARG("id")="SITE;3" + S ARG("detailed")="true" + D GET^VPRJPSTATUS(.DATA,.ARG) + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; this Sync Status should always be completed + D ASSERT(10,$D(OBJECT("inProgress")),"Sync status is not completed") + D ASSERT(0,$D(OBJECT("completedStamp")),"Sync status is completed and shouldn't be") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","hasSyncError")),"doesn't have hasSyncError when it should") + ; Allergy domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","hasSyncError")),"allergy domain should have hasSyncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should have syncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should have syncError") + ; Vitals domain should be complete + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","hasSyncError")),"vitals domain should have hasSyncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1001","syncError")),"Vital SITE:3:1001 should have syncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp","urn:va:vitals:SITE:3:1002","syncError")),"Vital SITE:3:1002 should have syncError") + K @DATA + Q +GETFILTERSYNCERROR ;; @TEST Get Patient Sync Status with filters (SYNC) + N DATA,ARG,ERR,OBJECT,HTTPERR + K ^TMP("HTTPERR",$J) + D BLANK + ; + S ARG("id")="SITE;3" + ; Set complete flags + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"stored")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1001",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","allergy","urn:va:allergy:SITE:3:1002",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1001",20141031094920,"syncError")=1 + S ^VPRSTATUS("52833885-af7c-4899-90be-b3a6630b2369","SITE;3","SITE","vitals","urn:va:vitals:SITE:3:1002",20141031094920,"syncError")=1 + ; Test that syncCompleted + K DATA,OBJECT + K ARG("detailed") + ; Test that sync has been complete when not in detailed mode + S ARG("filter")="exists(""hasSyncError"")" + D GET^VPRJPSTATUS(.DATA,.ARG) + ; If data is blank force error and quit + I $D(DATA)=0 D ASSERT(0,1,"Return variable is blank") Q + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + ; Test filters while in completedStamp + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy")),"Allergy domain does not exist and it should") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals")),"Vitals domain does not exist and it should") + ; + K DATA,OBJECT + S ARG("detailed")="true" + ; Test that domain has been stored when in detailed mode + S ARG("filter")="eq(""domain"",""allergy""),exists(""syncError"")" + D GET^VPRJPSTATUS(.DATA,.ARG) + ; If data is blank force error and quit + I $D(DATA)=0 D ASSERT(0,1,"Return variable is blank") Q + D DECODE^VPRJSON(DATA,"OBJECT","ERR") + ; If we can't decode the JSON Fail the test + D ASSERT(0,$D(ERR),"ERROR DECODING JSON") + D ASSERT(10,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp")),"Allergy domain does not exist and it should") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1001","syncError")),"Allergy SITE:3:1001 should have syncError") + D ASSERT("true",$G(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","allergy","eventMetaStamp","urn:va:allergy:SITE:3:1002","syncError")),"Allergy SITE:3:1002 should have syncError") + D ASSERT(0,$D(OBJECT("inProgress","sourceMetaStamp","SITE","domainMetaStamp","vitals","eventMetaStamp")),"Vitals domain exists and it should not") + Q ; diff --git a/VPRJTX.m b/VPRJTX.m old mode 100755 new mode 100644 index 044e43d..e7223db --- a/VPRJTX.m +++ b/VPRJTX.m @@ -1,5 +1,4 @@ VPRJTX ;SLC/KCM -- Utilities for unit tests - ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; BLDPT(TAGS) ; Build test patient for integration tests with data in TAGS ; TAGS(n)=TAG^RTN ; entry point for each JSON object, zzzzz terminated @@ -77,7 +76,7 @@ D GETDATA($P(TAG,"^"),$P(TAG,"^",2),.DATA) . D CLEARPT^VPRJPS(ICN) K VPRJTPID K HTTPREQ,HTTPERR,HTTPRSP - K ^TMP($J),^TMP("HTTPERR",$J) + K ^||TMP($J),^||TMP("HTTPERR",$J) Q ODSBLD(TAGS) ; Build sample data in non-patient data store ; TAGS(n)=TAG^RTN ; entry point for each JSON object, zzzzz terminated @@ -93,7 +92,7 @@ S HTTPREQ("store")="data" D DELCTN^VPRJDS("test") D DELCTN^VPRJDS("testb") D DELCTN^VPRJDS("utestods") - K ^TMP($J),^TMP("HTTPERR",$J) + K ^||TMP($J),^||TMP("HTTPERR",$J) Q GETDATA(TAG,RTN,DATA) ; load data from TAG^RTN into .DATA until zzzzz N I,L,X,OBJ @@ -127,6 +126,16 @@ S HTTPREQ("query")=$P(URL,"?",2,999) D GETDATA(TAG,RTN,.DATA) M HTTPREQ("body")=DATA Q +SETPOST(URL,TAG,RTN,SKIP) ; set up a POST request based on data in TAG^RTN + N DATA + D:'$G(SKIP) PATIDS + S HTTPERR=0 + S HTTPREQ("method")="POST" + S HTTPREQ("path")=$P(URL,"?") + S HTTPREQ("query")=$P(URL,"?",2,999) + D GETDATA(TAG,RTN,.DATA) + M HTTPREQ("body")=DATA + Q SETDEL(URL) ; set up a delete request S HTTPERR=0 S HTTPREQ("method")="DELETE" diff --git a/VPRJTZ.m b/VPRJTZ.m old mode 100755 new mode 100644 index 00f5033..f23dea6 --- a/VPRJTZ.m +++ b/VPRJTZ.m @@ -68,8 +68,8 @@ D BLDSPEC(.FIELDS,.SPEC) . . I $L(PTRN) S $P(PTRNVAL,":",J)=PTRNS(PTRN) . . S SUBS=SUBS_","_$S($E(SEG)="{":"""?""",+SEG=SEG:SEG,1:""""_SEG_"""") . S CNT=CNT+1,SUBS=SUBS_",""/"","_CNT_")",@SUBS=PTRNVAL - W ! ZW MAP - W ! ZW PTRNS + W ! ZWRITE MAP + W ! ZWRITE PTRNS Q MATCH(METHOD,PATH,ROUTINE,ARGS) ; Given method and path return routine and arguments N ISEG,SEG,URLSIG,TRYSIG,FAIL diff --git a/VPRJUCD.m b/VPRJUCD.m old mode 100755 new mode 100644 index 7516580..868f382 --- a/VPRJUCD.m +++ b/VPRJUCD.m @@ -276,5 +276,4 @@ D ASSERT("TARGET(""list"",J)",TLT("test","collection","testa","list[]","tgtRef") N TLT D BLDTLT("TLT5",.TLT) D ASSERT(0,$D(TLT("errors"))) - ;W ! ZW TLT Q diff --git a/VPRJUCD1.m b/VPRJUCD1.m old mode 100755 new mode 100644 diff --git a/VPRJUCF.m b/VPRJUCF.m old mode 100755 new mode 100644 diff --git a/VPRJUCR.m b/VPRJUCR.m old mode 100755 new mode 100644 diff --git a/VPRJUCT.m b/VPRJUCT.m old mode 100755 new mode 100644 diff --git a/VPRJUCU.m b/VPRJUCU.m old mode 100755 new mode 100644 diff --git a/VPRJUCV.m b/VPRJUCV.m old mode 100755 new mode 100644 index fb42afb..d425ab8 --- a/VPRJUCV.m +++ b/VPRJUCV.m @@ -42,8 +42,6 @@ S OBJECT("list",3)="list 3" N I,X,LINES,CLTN,SPEC S I=0 F S I=I+1,X=$P($T(@TAG+I),";;",2,99) Q:X="zzzzz" S LINES(I)=X D BLDSPEC^VPRJCD("template",.LINES,.SPEC,.CLTN) - ;W ! ZW SPEC ZW CLTN - ;D GETVALS^VPRJCV(.OBJECT,.VALUES,.CSPEC) Q TLTVALS ;; TEST set values for templates ;;unit-test-instance @@ -145,7 +143,6 @@ D SETOBJ(.OBJECT) S FIELDS(0,1)="ary1[].val/P" S FIELDS(0,2)="ary1[].ary2[].val/P" D BLD4IDX(.OBJECT,.VALUES,.FIELDS) - ;W ! ZW VALUES Q IDXNEST2 ;; @TEST indexing values with various ancestry paths N OBJECT,VALUES,FIELDS @@ -167,7 +164,6 @@ S FIELDS(0,2)="one[].two[].three[].z/P" S FIELDS(0,3)="one[].two[].y/P" S FIELDS(0,4)="one[].two[].five[].w/P" D BLD4IDX(.OBJECT,.VALUES,.FIELDS) - ;W ! ZW VALUES Q SETVALM ;; @TEST set values for deeper hierarchies like microbiology N OBJECT,VALUES,FIELDS diff --git a/VPRJUFPS.m b/VPRJUFPS.m old mode 100755 new mode 100644 diff --git a/VPRJUJ01.m b/VPRJUJ01.m old mode 100755 new mode 100644 diff --git a/VPRJUJ02.m b/VPRJUJ02.m old mode 100755 new mode 100644 diff --git a/VPRJUJD.m b/VPRJUJD.m old mode 100755 new mode 100644 index e1177e7..dd8a779 --- a/VPRJUJD.m +++ b/VPRJUJD.m @@ -1,4 +1,4 @@ -VPRJUJD ;SLC/KCM -- Unit tests for JSON decoding +VPRJUJD ;SLC/KCM,CPC -- Unit tests for JSON decoding ;;1.0;JSON DATA STORE;;Sep 01, 2012 ; STARTUP ; Run once before all tests @@ -152,6 +152,12 @@ D ASSERT(1,$D(ERR)>0) D BUILD("BADSLASH",.JSON) D DECODE^VPRJSON("JSON","Y","ERR") D ASSERT(1,$D(ERR)>0) Q +BADBRACK ;; @TEST poorly formed JSON (additional close bracket) + N JSON,Y,ERR + S JSON="{""error"":{""message"":""An error occurred""}}}" + D DECODE^VPRJSON("JSON","Y","ERR") + D ASSERT(1,$D(ERR)>0) + Q PSNUM ;; @TEST subjects that look like a numbers shouldn't be encoded as numbers N JSON,Y,ERR D BUILD("PSNUM",.JSON) diff --git a/VPRJUJE.m b/VPRJUJE.m old mode 100755 new mode 100644 diff --git a/VPRJUREQ.m b/VPRJUREQ.m old mode 100755 new mode 100644 diff --git a/VPRJURSP.m b/VPRJURSP.m old mode 100755 new mode 100644 index c346bdc..96c7559 --- a/VPRJURSP.m +++ b/VPRJURSP.m @@ -25,6 +25,16 @@ D ASSERT("desc",QRY("order")) D ASSERT(5,QRY("limit")) Q ; +QSPLITURLENCODE ;; @TEST splitting query parameters that are URL encoded + N QRY,HTTPERR + S HTTPREQ("query")="range=%22record-enrichment%22%3E%22job%22%26limit%3D1000%26filter=lt(job.retryCount%2C5)" + D QSPLIT^VPRJRSP(.QRY) + D ASSERT($D(QRY("range")),1) + D ASSERT("""record-enrichment"">""job""",QRY("range")) + D ASSERT(1000,QRY("limit")) + D ASSERT("lt(job.retryCount,5)",QRY("filter")) + Q + ; SETREQ(METHOD,URL) ; set up a request (to emulate HTTP call) S HTTPREQ("method")=METHOD S HTTPREQ("path")=$P(URL,"?") diff --git a/VPRJURUT.m b/VPRJURUT.m old mode 100755 new mode 100644 diff --git a/VPRJUSR.m b/VPRJUSR.m old mode 100755 new mode 100644 index 2bd9b85..c73e5bd --- a/VPRJUSR.m +++ b/VPRJUSR.m @@ -12,7 +12,7 @@ L +^VPRJUSR(SID):$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q "" TSTART I $O(^VPRJUSR(SID,""))']"" S INCR=$I(^VPRJUSR(0)) - K ^VPRJUSR(SID) + K:$D(^VPRJUSR(SID)) ^VPRJUSR(SID) M ^VPRJUSR(SID)=DEMOG TCOMMIT L -^VPRJUSR(SID) @@ -24,7 +24,7 @@ L +^VPRJUSR:$G(^VPRCONFIG("timeout","gds"),5) E D SETERROR^VPRJRER(502) Q S VPRJA=0 TSTART - F S VPRJA=$O(^VPRJUSR(VPRJA)) Q:VPRJA']"" K ^VPRJUSR(VPRJA) + F S VPRJA=$O(^VPRJUSR(VPRJA)) Q:VPRJA']"" K:$D(^VPRJUSR(VPRJA)) ^VPRJUSR(VPRJA) S ^VPRJUSR(0)=0 TCOMMIT L -^VPRJUSR @@ -36,7 +36,7 @@ I $D(^VPRJUSR(ARGS("_id"))) D .L +^VPRJUSR(ARGS("_id")):$G(^VPRCONFIG("timeout","gds"),5) .TSTART - .K ^VPRJUSR(ARGS("_id")) + .K:$D(^VPRJUSR(ARGS("_id"))) ^VPRJUSR(ARGS("_id")) .TCOMMIT .L -^VPRJUSR(ARGS("_id")) S RESULT="{}" @@ -56,7 +56,9 @@ N DEMOG,ERR,BODY,SID I $$UNKARGS^VPRJCU(.ARGS,"_id") Q S SID=ARGS("_id") + L +^VPRJUSR(ARGS("_id")):$G(^VPRCONFIG("timeout","gds"),5) M DEMOG=^VPRJUSR(SID) + L -^VPRJUSR(ARGS("_id")) D ENCODE^VPRJSON("DEMOG","BODY","ERR") ; From an array to JSON I $D(ERR) D SETERROR^VPRJRER(202) Q M RESULT=BODY diff --git a/VPRJUTLN.m b/VPRJUTLN.m new file mode 100644 index 0000000..ea9f733 --- /dev/null +++ b/VPRJUTLN.m @@ -0,0 +1,109 @@ +VPRJUTLN ;V4W/DLW -- Utilities for wrapper functions called by cache.node + ; + QUIT + ; + ; Generate unique identifier for output data used (along with $JOB) to avoid race conditions from asynchronous JS code + ; + ; @return {string} UUID - A UUID or a <1:UUID EXCEPTION> error string to return to jds-cache-api +GENUUID() + N FLAG,I + ; + S FLAG=1 + F I=1:1:10 S UUID=$$UUID^VPRJRUT I '$D(^TMP(UUID,$J)),'$D(^TMP("HTTPERR",UUID,$J)) S FLAG=0 Q + I FLAG QUIT "1:UUID EXCEPTION" + ; + QUIT UUID + ; + ; Common setup tasks to create the environment for the underlying endpoint call + ; + ; @return {none} +SETUP + ; Set defaults if not passed by jds-cache-api code + S START=$G(START,0) + S LIMIT=$G(LIMIT,999999) + S STARTID=$G(STARTID) + ; Passes as true/false, but we need 1/0 + I $G(RETCNTS)="true" S RETCNTS=1 + E S RETCNTS=0 + ; + ; JDS uses this to flag whether there is an error or not + S HTTPERR=0 + ; clean any old data + K:$D(^||TMP($J)) ^||TMP($J) + K:$D(^||TMP("HTTPERR",$J)) ^||TMP("HTTPERR",$J) + ; + QUIT + ; + ; Stage return data in an M global array, for retrieveQueryResult in jds-cache-api clients + ; + ; @param {array} RESULT - (passed by reference) An array containg the return type of the staged data + ; @return {string} UUID - A UUID used to stage the return data to retrieveQueryResult in order to avoid races + ; @param {string} START - The offset (by count of items) to begin at to add to the return array + ; @param {string} LIMIT - Limit of items (by count) to add to the return array + ; @param {string} STARTID - The first item (by item number or uid) to add to the return array + ; @param {string} RETCNTS - Return a header with the totalItems and currentItemCount + ; @return {string} RETURN - <0|1>: Error code followed by UUID key +RETURNDATA(RESULT,UUID,START,LIMIT,STARTID,RETCNTS) ; Return data to jds-cache-api + N SIZE,PREAMBLE,POSTAMBLE,RETURN + ; + ; if there is an error, do not attempt to paginate + I $G(HTTPERR) K RESULT("pageable") + ; + ; equivalent to RSPTYPE=3 + I $D(RESULT("pageable")) D + . ; support for start, limit, startid, and returncounts for pageable data + . I STARTID'="" F I=1:1:$G(@RESULT@("total")) I $D(@RESULT@("data",I,STARTID)) S START=START+I Q + . ; stage output data + . D PAGE^VPRJRUT(.RESULT,START,LIMIT,.SIZE,.PREAMBLE,RETCNTS) + . ; + . ; set ending JSON appropriately by store type + . I RESULT("pageable")="gds" D + . . ; set ending JSON appropriately based on whether there is data or not + . . I PREAMBLE["[" S POSTAMBLE="]}" + . . E S POSTAMBLE="}" + . E S POSTAMBLE="]}}" + . ; store data so that jds-cache-api can retrieve it + . ; return a 1 to represent JDS error, 0 for JDS success + . I $G(HTTPERR) M ^TMP("HTTPERR",UUID,$J)=^||TMP("HTTPERR",$J) S RETURN=1_":"_UUID + . E M ^TMP(UUID,$J,"PREAMBLE")=PREAMBLE,^TMP(UUID,$J)=@RESULT@($J) D + . . S ^TMP(UUID,$J,"POSTAMBLE")=POSTAMBLE + . . ; set status code for jds-cache-api + . . I $G(URL)'="" S ^TMP(UUID,$J,"STATUS")=201 + . . E S ^TMP(UUID,$J,"STATUS")=200 + . . S RETURN=0_":"_UUID + ; equivalent to RSPTYPE=2 + E I $E($G(RESULT))="^" D + . ; store data so that jds-cache-api can retrieve it + . ; return a 1 to represent JDS error, 0 for JDS success + . I $G(HTTPERR) M ^TMP("HTTPERR",UUID,$J)=^||TMP("HTTPERR",$J) S RETURN=1_":"_UUID + . E M ^TMP(UUID,$J)=@RESULT D + . . ; set status code for jds-cache-api + . . I $G(URL)'="" S ^TMP(UUID,$J,"STATUS")=201 + . . E S ^TMP(UUID,$J,"STATUS")=200 + . . S RETURN=0_":"_UUID + ; equivalent to RSPTYPE=1 + E D + . ; store data so that jds-cache-api can retrieve it + . ; return a 1 to represent JDS error, 0 for JDS success + . I $G(HTTPERR) M ^TMP("HTTPERR",UUID,$J)=^||TMP("HTTPERR",$J) S RETURN=1_":"_UUID + . E M ^TMP(UUID,$J)=RESULT D + . . ; set status code for jds-cache-api + . . I $G(URL)'="" S ^TMP(UUID,$J,"STATUS")=201 + . . E S ^TMP(UUID,$J,"STATUS")=200 + . . S RETURN=0_":"_UUID + ; + QUIT RETURN + ; + ; Stage return data in an M global array, for retrieveQueryResult in jds-cache-api clients + ; + ; @param {array} BODY - (passed by reference) A container array used to pass back the JSON result to the wrapper calls + ; @param {string} NODEUUID - UUID that jds-cache-api used to stage the set data, used (along with $JOB) to avoid races + ; @return {none} +STAGEDATA(BODY,NODEUUID) ; Stage data for storage from jds-cache-api + K BODY + M BODY=^TMP("BODY",NODEUUID,$J,"data") + ; + K:$D(^TMP("BODY",NODEUUID,$J)) ^TMP("BODY",NODEUUID,$J) + ; + QUIT + ; diff --git a/VPRJVER.m b/VPRJVER.m old mode 100755 new mode 100644 diff --git a/VPRJVUP.m b/VPRJVUP.m old mode 100755 new mode 100644 index ca8ae3a..464733a --- a/VPRJVUP.m +++ b/VPRJVUP.m @@ -8,7 +8,7 @@ ; UPGRADE ; upgrade JDS (assume new routines are loaded) N LASTVER,THISVER - K ^XTMP("VPRJVUP") ; -- reset upgrade log for + K:$D(^XTMP("VPRJVUP")) ^XTMP("VPRJVUP") ; -- reset upgrade log for S ^XTMP("VPRJVUP","odc")="" ; rebuild status calls S ^XTMP("VPRJVUP","vpr")="" S ^VPRHTTP(0,"updating")=1 ; -- set upgrade flag @@ -21,9 +21,9 @@ W !,"Upgrading from "_LASTVER_" to "_THISVER,! Q UPGBACK ; upgrade as background process - D FULLRBLD^VPRJ ; -- full rebuild of VPR and ODC - K ^VPRHTTP(0,"updating") ; -- clear upgrade flag - D GO^VPRJRCL ; -- start listener + D FULLRBLD^VPRJ ; -- full rebuild of VPR and ODC + K:$D(^VPRHTTP(0,"updating")) ^VPRHTTP(0,"updating") ; -- clear upgrade flag + D GO^VPRJRCL ; -- start listener Q WATCH ; watch the progress of the upgrade N X @@ -41,15 +41,15 @@ I '$D(^VPRPTJ("JSON")),$D(^VPRPT("JSON")) D . M ^VPRPTJ("JSON")=^VPRPT("JSON") ; preserve patient data . K ^VPRPT("JSON") - . K ^VPRPT("TEMPLATE") ; we'll rebuild the rest - . K ^VPRPT("KEY") - . K ^VPRPT("PID") + . K:$D(^VPRPT("TEMPLATE")) ^VPRPT("TEMPLATE") ; we'll rebuild the rest + . K:$D(^VPRPT("KEY")) ^VPRPT("KEY") + . K:$D(^VPRPT("PID")) ^VPRPT("PID") ; ; move the JSON into the ^VPRJDJ global I '$D(^VPRJDJ("JSON")),$D(^VPRJD("JSON")) D . M ^VPRJDJ("JSON")=^VPRJD("JSON") ; preserve operational data . K ^VPRJD("JSON") - . K ^VPRJD("TEMPLATE") + . K:$D(^VPRJD("TEMPLATE")) ^VPRJD("TEMPLATE") Q CNVRT61 ; Convert syncstatus objects for version 0.7-S61 N ROOT,JSON,UID,LROOT,DFN,SITE,PID,DNM,PITER,PTUID,LOCIDS,JPID diff --git a/VPRSTATUS.m b/VPRSTATUS.m deleted file mode 100755 index 572135e..0000000 --- a/VPRSTATUS.m +++ /dev/null @@ -1,49 +0,0 @@ -VPRSTATUS ;KRM/CJE -- Handle Sync Status operations - ; No entry from top - Q - ; -CLEAR(RESULT,ARGS) ; Delete all sync status data - K ^VPRSTATUS - Q -DELSS(PID) ; Delete a patient's sync status - K ^VPRSTATUS(PID) - Q -DELSITE(SITE) ; Delete a site's sync status - N PID - S PID=SITE - F S PID=$O(^VPRPT(PID)) Q:PID=""!($P(PID,";")'=SITE) D - . K ^VPRSTATUS(PID) - Q -STORERECORD(RESULT,BODY) - ; Testing endpoint - N OBJECT,ERR,PID,SOURCE,SOURCESTAMP,DOMAIN,UID,EVENTSTAMP,K - D DECODE^VPRJSON("BODY","OBJECT","ERR") - S PID=$G(OBJECT("pid")) - S SOURCE=$G(OBJECT("source")) - S UID=$G(OBJECT("uid")) - S DOMAIN=$G(OBJECT("domain")) - S EVENTSTAMP=$G(OBJECT("eventStamp")) - S SOURCESTAMP="" - I $D(^VPRSTATUS(PID,SOURCE,DOMAIN,UID,EVENTSTAMP)) S ^VPRSTATUS(PID,SOURCE,DOMAIN,UID,EVENTSTAMP,"stored")="1" - Q "" - ; - ; Operational data sync status - ; -DELOD(RESULT,ARGS) ; Delete all sync status data - ; If we are passed an id only kill that site's sync status - I $G(ARGS("id"))'="" K ^VPRSTATUSOD(ARGS("id")) Q - ; If no id passed kill the whole thing - I $G(ARGS("id"))="" K ^VPRSTATUSOD - Q -STORERECORDOD(RESULT,BODY) - ; Testing endpoint - N OBJECT,ERR,SOURCE,SOURCESTAMP,DOMAIN,UID,ITEMSTAMP,K - D DECODE^VPRJSON("BODY","OBJECT","ERR") - S SOURCE=$G(OBJECT("source")) - S UID=$G(OBJECT("uid")) - S DOMAIN=$G(OBJECT("domain")) - S ITEMSTAMP=$G(OBJECT("itemStamp")) - S SOURCESTAMP="" - F K=1:1 S SOURCESTAMP=$O(^VPRSTATUSOD(SOURCE,SOURCESTAMP)) Q:SOURCESTAMP="" D - . I $D(^VPRSTATUSOD(SOURCE,SOURCESTAMP,DOMAIN,UID,ITEMSTAMP)) S ^VPRSTATUSOD(SOURCE,SOURCESTAMP,DOMAIN,UID,ITEMSTAMP,"stored")="1" - Q "" diff --git a/VPRSTMP.m b/VPRSTMP.m old mode 100755 new mode 100644 diff --git a/XLFCRC.m b/XLFCRC.m old mode 100755 new mode 100644 diff --git a/XLFDT.m b/XLFDT.m old mode 100755 new mode 100644 diff --git a/XLFDT1.m b/XLFDT1.m old mode 100755 new mode 100644 diff --git a/XLFSTR.m b/XLFSTR.m old mode 100755 new mode 100644 diff --git a/XLFUTL.m b/XLFUTL.m old mode 100755 new mode 100644 diff --git a/_ut.m b/_ut.m new file mode 100644 index 0000000..3b4aa03 --- /dev/null +++ b/_ut.m @@ -0,0 +1,468 @@ +%ut ;VEN-SMH/JLI - PRIMARY PROGRAM FOR M-UNIT TESTING ;04/08/16 20:35 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Joel L. Ivey as XTMUNIT while working for U.S. Department of Veterans Affairs 2003-2012 + ; Includes addition of %utVERB and %utBREAK arguments and code related to them as well as other substantial additions authored by Sam Habiel 07/2013-04/2014 + ; Additions and modifications made by Sam H. Habiel and Joel L. Ivey 02/2016-04/2016 + ; + ; This routine and its companion, %ut1, provide the basic functionality for + ; running unit tests on parts of M programs either at the command line level + ; or via the M-Unit GUI application for windows operating systems. + ; + ; Original by Dr. Joel Ivey + ; Contributions by Dr. Sam Habiel + ; comments moved to %utcover due to space requirements + ; + D ^%utt6 ; runs unit tests on all of it + Q + ; +EN(%utRNAM,%utVERB,%utBREAK) ; .SR Entry point with primary test routine name + ; %utRNAM: (Required) Routine name that contians the tags with @TEST in them or the tag XTROU + ; %utVERB: (optional) 1 for verbose output or 2 for verbose and timing info. + ; %utBREAK:(optional) bool - Break upon error or upon failure + N %utLIST,%utROU,%ut + S %utLIST=1,%utROU(%utLIST)=%utRNAM + K ^TMP("%ut",$J,"UTVALS") + D SETUT + D EN1(.%utROU,%utLIST) + Q + ; +SETUT ; + ; VEN/SMH 26JUL2013 + I '($D(IO)#2) S IO=$P + S U="^" + ; VEN/SMH 26JUL2013 END + ; + ; ZEXCEPT: %ut -- NEWED ON ENTRY + S %ut("IO")=IO + S %ut=1 ; set to identify unit test being run check with $$ISUTEST^%ut() + ; + ; ZEXCEPT: %utBREAK + I $G(%utBREAK) S %ut("BREAK")=1 + Q + ; +EN1(%utROU,%utLIST) ; + ; VEN/SMH 26JUL2013 - This block is refactored to fix problems with + ; SETUP and TEARDOWN not happening at the right time + N %utERRL,%utK,%utI,%utJ,%utSTRT + ; ZEXCEPT: %utVERB -- ARGUMENT TO EN + I '+$G(%utVERB) S %utVERB=0 + ; ZEXCEPT: %utGUI -- CONDITIONALLY DEFINED BY GUINEXT + ; ZEXCEPT: %ut -- NEWED IN EN + ; ZEXCEPT: GetCPUTime,Process -- part of Cache method names + ; + ; Structure map for %ut + ; -- CURR = Counter for routine number. Used as sub in %utROU + ; -- ECNT = Entry point count in loop (cf. NERT); VEN/SMH - Needed? + ; -- FAIL = Number of failures + ; -- CHK = Number of checks ran (TF/EQ/FAIL) + ; -- NENT = Number of entry points ran + ; -- ERRN = Number of errors + S %ut("CURR")=0,%ut("ECNT")=0,%ut("FAIL")=0,%ut("CHK")=0,%ut("NENT")=0,%ut("ERRN")=0 + ; + ; -- GET LIST OF ROUTINES -- + ; first get any tree of routines from this one + D GETTREE^%ut1(.%utROU,.%utLIST) + ; + ; Now process each routine that has been referenced + N CURRROU + S %ut("CURR")=0 + F S %ut("CURR")=%ut("CURR")+1 Q:'$D(%utROU(%ut("CURR"))) S CURRROU=%utROU(%ut("CURR")) D I $T(@("SHUTDOWN^"_CURRROU))'="" D @("SHUTDOWN^"_CURRROU) + . ; 141018 - add ability to run STARTUP and SHUTDOWN in each routine JLI + . I $T(@("STARTUP^"_CURRROU))'="" D @("STARTUP^"_CURRROU) ; 141018 + . N %utETRY ; Test list to run + . ; + . ; Collect Test list. + . D CHEKTEST^%ut1(%utROU(%ut("CURR")),.%ut,.%utETRY) + . ; + . ; if a SETUP entry point exists, save it off in %ut + . S %ut("SETUP")="" ; 141018 need to clear any previous values JLI + . N %utSETUP S %utSETUP="SETUP^"_%utROU(%ut("CURR")) + . S %ut("LINE")=$T(@%utSETUP) I %ut("LINE")'="" S %ut("SETUP")=%utSETUP + . K %utSETUP ; we're done! + . ; + . ; if a TEARDOWN entry point exists, ditto + . S %ut("TEARDOWN")="" ; 141018 need to clear any previous values JLI + . N %utTEARDOWN S %utTEARDOWN="TEARDOWN^"_%utROU(%ut("CURR")) + . S %ut("LINE")=$T(@%utTEARDOWN) I %ut("LINE")'="" S %ut("TEARDOWN")=%utTEARDOWN + . K %utTEARDOWN ; done here. + . ; + . ; VEN/SMH 26JUL2013 - this block changed to correct running of setup and teardown + . ; run each of the specified entry points + . ; + . ; == THIS FOR/DO BLOCK IS THE CENTRAL TEST RUNNER == + . S %utI=0 + . F S %utI=$O(%utETRY(%utI)) Q:%utI'>0 S %ut("ENUM")=%ut("ERRN")+%ut("FAIL") D + . . N $ETRAP S $ETRAP="D ERROR^%ut" + . . ; + . . ; Run Set-up Code (only if present) + . . S %ut("ENT")=$G(%ut("SETUP")) ; Current entry + . . S %ut("NAME")="Set-up Code" + . . D:%ut("ENT")]"" @%ut("ENT") + . . ; + . . ; Run actual test + . . S %ut("ECNT")=%ut("ECNT")+1 + . . S %ut("NAME")=%utETRY(%utI,"NAME") + . . S %ut("ENT")=%utETRY(%utI)_"^"_%utROU(%ut("CURR")) + . . I %utVERB,'$D(%utGUI) D VERBOSE1(.%utETRY,%utI) ; Say what we executed. + . . ; + . . I %utVERB=2 N %utStart D ; Time Start + . . . I +$SY=0 S %utStart=$P($SYSTEM.Process.GetCPUTime(),",")+$P($SYSTEM.Process.GetCPUTime(),",",2) + . . . I +$SY=47 S %utStart=$ZGETJPI("","CPUTIM")*10 + . . ; + . . ; Run the test! + . . D @%ut("ENT") + . . ; + . . I %utVERB=2 N %utEnd,%utElapsed D ; Time End + . . . I +$SY=0 S %utEnd=$P($SYSTEM.Process.GetCPUTime(),",")+$P($SYSTEM.Process.GetCPUTime(),",",2) + . . . I +$SY=47 S %utEnd=$ZGETJPI("","CPUTIM")*10 + . . . S %utElapsed=%utEnd-%utStart_"ms" + . . ; + . . ; Run Teardown Code (only if present) + . . S %ut("ENT")=$G(%ut("TEARDOWN")) + . . S %ut("NAME")="Teardown Code" + . . D:%ut("ENT")]"" @%ut("ENT") + . . ; + . . ; ENUM = Number of errors + failures + . . ; Only print out the success message [OK] If our error number remains + . . ; the same as when we started the loop. + . . I %utVERB,'$D(%utGUI) D + . . . I %ut("ENUM")=(%ut("ERRN")+%ut("FAIL")) D VERBOSE(.%utETRY,1,%utVERB,$G(%utElapsed)) I 1 + . . . E D VERBOSE(.%utETRY,0,%utVERB,$G(%utElapsed)) + . . . Q + . . Q + . ; keep a %utCNT of number of entry points executed across all routines + . S %ut("NENT")=%ut("NENT")+%ut("ENTN") + . Q + ; + ; -- SHUTDOWN -- + D SETIO^%ut1 + W !!,"Ran ",%utLIST," Routine",$S(%utLIST>1:"s",1:""),", ",%ut("NENT")," Entry Tag",$S(%ut("NENT")>1:"s",1:"") + W !,"Checked ",%ut("CHK")," test",$S(%ut("CHK")>1:"s",1:""),", with ",%ut("FAIL")," failure",$S(%ut("FAIL")'=1:"s",1:"")," and encountered ",%ut("ERRN")," error",$S(%ut("ERRN")'=1:"s",1:""),"." + S ^TMP("%ut",$J,"UTVALS")=%utLIST_U_%ut("NENT")_U_%ut("CHK")_U_%ut("FAIL")_U_%ut("ERRN") ; JLI 150621 so programs running several sets of unit tests can generate totals + D RESETIO^%ut1 + Q + ; -- end EN1 +VERBOSE(%utETRY,SUCCESS,%utVERB,%utElapsed) ;Internal only - Say whether we succeeded or failed. + ; ZEXCEPT: %ut - NEWED IN EN + D SETIO^%ut1 + N RM S RM=73 ; Right Margin + I %utVERB=2,$G(%utElapsed)]"" S RM=RM-$L(%utElapsed)-1 + N I F I=$X+3:1:RM W "-" + W ?RM + I $G(SUCCESS) W "[OK]" + E W "[FAIL]" + I %utVERB=2,$G(%utElapsed)]"" W " ",%utElapsed ; add timing + D RESETIO^%ut1 + Q + ; +VERBOSE1(%utETRY,%utI) ; Print out the entry point info + ; ZEXCEPT: %ut - NEWED IN EN + D SETIO^%ut1 + W !,%utETRY(%utI) I $G(%utETRY(%utI,"NAME"))'="" W " - ",%utETRY(%utI,"NAME") + D RESETIO^%ut1 + Q + ; +CHKTF(XTSTVAL,XTERMSG) ; Entry point for checking True or False values + ; ZEXCEPT: %utERRL,%utGUI - CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: %ut - NEWED IN EN + ; ZEXCEPT: XTGUISEP - newed in GUINEXT + I '$D(XTSTVAL) D NVLDARG^%ut1("CHKTF") Q + I $G(XTERMSG)="" S XTERMSG="no failure message provided" + S %ut("CHK")=$G(%ut("CHK"))+1 + I '$D(%utGUI) D + . D SETIO^%ut1 + . I 'XTSTVAL W !,%ut("ENT")," - " W:%ut("NAME")'="" %ut("NAME")," - " D + . . W XTERMSG,! S %ut("FAIL")=%ut("FAIL")+1,%utERRL(%ut("FAIL"))=%ut("NAME"),%utERRL(%ut("FAIL"),"MSG")=XTERMSG,%utERRL(%ut("FAIL"),"ENTRY")=%ut("ENT") + . . I $D(%ut("BREAK")) BREAK ; Break upon failure + . . Q + . I XTSTVAL W "." + . D RESETIO^%ut1 + . Q + I $D(%utGUI),'XTSTVAL S %ut("CNT")=%ut("CNT")+1,@%ut("RSLT")@(%ut("CNT"))=%ut("LOC")_XTGUISEP_"FAILURE"_XTGUISEP_XTERMSG,%ut("FAIL")=%ut("FAIL")+1 + Q + ; +CHKEQ(XTEXPECT,XTACTUAL,XTERMSG) ; Entry point for checking values to see if they are EQUAL + N FAILMSG + ; ZEXCEPT: %utERRL,%utGUI -CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: %ut -- NEWED IN EN + ; ZEXCEPT: XTGUISEP - newed in GUINEXT + I '$D(XTEXPECT)!'$D(XTACTUAL) D NVLDARG^%ut1("CHKEQ") Q + S XTACTUAL=$G(XTACTUAL),XTEXPECT=$G(XTEXPECT) + I $G(XTERMSG)="" S XTERMSG="no failure message provided" + S %ut("CHK")=%ut("CHK")+1 + I XTEXPECT'=XTACTUAL S FAILMSG="<"_XTEXPECT_"> vs <"_XTACTUAL_"> - " + I '$D(%utGUI) D + . D SETIO^%ut1 + . I XTEXPECT'=XTACTUAL W !,%ut("ENT")," - " W:%ut("NAME")'="" %ut("NAME")," - " W FAILMSG,XTERMSG,! D + . . S %ut("FAIL")=%ut("FAIL")+1,%utERRL(%ut("FAIL"))=%ut("NAME"),%utERRL(%ut("FAIL"),"MSG")=XTERMSG,%utERRL(%ut("FAIL"),"ENTRY")=%ut("ENT") + . . I $D(%ut("BREAK")) BREAK ; Break upon failure + . . Q + . E W "." + . D RESETIO^%ut1 + . Q + I $D(%utGUI),XTEXPECT'=XTACTUAL S %ut("CNT")=%ut("CNT")+1,@%ut("RSLT")@(%ut("CNT"))=%ut("LOC")_XTGUISEP_"FAILURE"_XTGUISEP_FAILMSG_XTERMSG,%ut("FAIL")=%ut("FAIL")+1 + Q + ; +FAIL(XTERMSG) ; Entry point for generating a failure message + D FAIL^%ut1($G(XTERMSG)) + Q + ; +SUCCEED ; Entry point for forcing a success (Thx David Whitten) + ; ZEXCEPT: %utERRL,%utGUI - CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: %ut - NEWED IN EN + ; Switch IO and write out the dot for activity + I '$D(%utGUI) D + . D SETIO^%ut1 + . W "." + . D RESETIO^%ut1 + ; + ; Increment test counter + S %ut("CHK")=%ut("CHK")+1 + QUIT + ; +CHKLEAKS(%utCODE,%utLOC,%utINPT) ; functionality to check for variable leaks on executing a section of code + ; %utCODE - A string that specifies the code that is to be XECUTED and checked for leaks. + ; this should be a complete piece of code (e.g., "S X=$$NOW^XLFDT()" or "D EN^%ut(""ROUNAME"")") + ; %utLOC - A string that is used to indicate the code tested for variable leaks + ; %utINPT - An optional variable which may be passed by reference. This may + ; be used to pass any variable values, etc. into the code to be + ; XECUTED. In this case, set the subscript to the variable name and the + ; value of the subscripted variable to the desired value of the subscript. + ; e.g., (using NAME as my current namespace) + ; S CODE="S %utINPT=$$ENTRY^ROUTINE(ZZVALUE1,ZZVALUE2)" + ; S NAMELOC="ENTRY^ROUTINE leak test" (or simply "ENTRY^ROUTINE") + ; S NAMEINPT("ZZVALUE1")=ZZVALUE1 + ; S NAMEINPT("ZZVALUE2")=ZZVALUE2 + ; D CHKLEAKS^%ut(CODE,NAMELOC,.NAMEINPT) + ; + ; If part of a unit test, any leaked variables in ENTRY^ROUTINE which result + ; from running the code with the variables indicated will be shown as FAILUREs. + ; + ; If called outside of a unit test, any leaked variables will be printed to the + ; current device. + ; + N (%utCODE,%utLOC,%utINPT,DUZ,IO,U,%utERRL,%ut,%utGUI,%utERR,%utI,%utJ,%utK,%utLIST,%utROU,%utSTRT,XTGUISEP) + ; ZEXCEPT: %ut - part of exclusive NEW TESTS FOR EXISTENCE ONLY + ; ZEXCEPT: %utVAR - handled by exclusive NEW + ; + ; ACTIVATE ANY VARIABLES PASSED AS SUBSCRIPTS TO %utINPT TO THEIR VALUES + S %utVAR=" " F S %utVAR=$O(%utINPT(%utVAR)) Q:%utVAR="" S (@%utVAR)=%utINPT(%utVAR) + X %utCODE + N ZZUTVAR S ZZUTVAR="%" + I $G(%ut)=1 D + . I $D(@ZZUTVAR),'$D(%utINPT(ZZUTVAR)) D FAIL^%ut(%utLOC_" VARIABLE LEAK: "_ZZUTVAR) + . F S ZZUTVAR=$O(@ZZUTVAR) Q:ZZUTVAR="" I $E(ZZUTVAR,1,3)'="%ut",'$D(%utINPT(ZZUTVAR)),",DUZ,IO,U,DTIME,ZZUTVAR,DT,%ut,XTGUISEP,"'[(","_ZZUTVAR_",") D FAIL^%ut(%utLOC_" VARIABLE LEAK: "_ZZUTVAR) + . Q + I '($G(%ut)=1) D + . I $D(@ZZUTVAR),'$D(%utINPT(ZZUTVAR)) W !,%utLOC_" VARIABLE LEAK: "_ZZUTVAR + . F S ZZUTVAR=$O(@ZZUTVAR) Q:ZZUTVAR="" I $E(ZZUTVAR,1,3)'="%ut",'$D(%utINPT(ZZUTVAR)),",DUZ,IO,U,DTIME,ZZUTVAR,DT,%ut,XTGUISEP,"'[(","_ZZUTVAR_",") W !,%utLOC_" VARIABLE LEAK: "_ZZUTVAR + . Q + Q + ; +ERROR ; record errors + ; ZEXCEPT: %utERRL,%utGUI,%utERR -CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: %ut -- NEWED ON ENTRY + ; ZEXCEPT: XTGUISEP - newed in GUINEXT + S %ut("CHK")=%ut("CHK")+1 + I '$D(%utGUI) D ERROR1 + I $D(%utGUI) D + . S %ut("CNT")=%ut("CNT")+1 + . S %utERR=%utERR+1 + . S @%ut("RSLT")@(%ut("CNT"))=%ut("LOC")_XTGUISEP_"ERROR"_XTGUISEP_$S(+$SY=47:$ZS,1:$ZE) + . Q + S @($S(+$SY=47:"$ZS",1:"$ZE")_"="_""""""),$EC="" + Q + ; +ERROR1 ; + I $G(%ut("BREAK")) BREAK ; if we are asked to break upon error, please do so! + ; ZEXCEPT: %utERRL -CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: %ut -- NEWED ON ENTRY + D SETIO^%ut1 + W !,%ut("ENT")," - " W:%ut("NAME")'="" %ut("NAME")," - Error: " W $S(+$SY=47:$ZS,1:$ZE),! D + . S %ut("ERRN")=%ut("ERRN")+1,%utERRL(%ut("ERRN"))=%ut("NAME"),%utERRL(%ut("FAIL"),"MSG")=$S(+$SY=47:$ZS,1:$ZE),%utERRL(%ut("FAIL"),"ENTRY")=%ut("ENT") + . Q + D RESETIO^%ut1 + Q + ; +ISUTEST() ; .SUPPORTED API TO DETERMINE IF CURRENTLY IN UNIT TEST + ; ZEXCEPT: %ut -- NEWED ON ENTRY + Q $G(%ut)=1 + ; +PICKSET ; .OPT Interactive selection of MUnit Test Group + N DIC,Y,%utROU,%utLIST,DIR + I '$$ISUTEST^%ut() S DIC=17.9001,DIC(0)="AEQM" D ^DIC Q:Y'>0 W ! D GETSET(+Y,.%utROU,.%utLIST) N DIC,Y,%ut D SETUT D EN1(.%utROU,%utLIST) S DIR(0)="EA",DIR("A")="Enter RETURN to continue:" D ^DIR K DIR + Q + ; +RUNSET(SETNAME,VERBOSE) ; .SR Run with Specified Selection of MUnit Test Group + N Y,%utROU,%utLIST,%utVERB + Q:$G(SETNAME)="" + S %utVERB=$G(VERBOSE,0) + S Y=+$$FIND1^DIC(17.9001,"","X",SETNAME) Q:Y'>0 + D GETSET(Y,.%utROU,.%utLIST) + N Y,SETNAME,%ut + D SETUT + D EN1(.%utROU,%utLIST) + Q + ; + ; DOSET CAN BE USED TO RUN A SET OF TESTS BASED ON THE IEN IN THE MUNIT TEST GROUP file (#17.9001) +DOSET(IEN,%utVERB) ; 140731 JLI added %utVERB as a second argument + ; IEN - Internal entry number for selected set of tests in the MUNIT TEST GROUP file (#17.9001) + ; %utVERB - optional input that indicates verbose output is permitted + ; + N %utROU,%utLIST + I '$D(%utVERB) S %utVERB=0 + S %utLIST=0 + D GETSET($G(IEN),.%utROU,.%utLIST) + I %utLIST>0 N IEN,%ut D SETUT,EN1(.%utROU,%utLIST) + Q + ; +GETSET(IEN,%utROU,%utLIST) ; JLI 140731 - called from PICKSET, RUNSET, DOSET, GUISET + N IENS,%utROOT + S IENS=IEN_"," D GETS^DIQ(17.9001,IENS,"1*","","%utROOT") + S %utLIST=0,IENS="" F S IENS=$O(%utROOT(17.90011,IENS)) Q:IENS="" S %utLIST=%utLIST+1,%utROU(%utLIST)=%utROOT(17.90011,IENS,.01) + Q + ; +COV(NMSP,COVCODE,VERBOSITY) ; simply make it callable from %ut1 as well (along with other APIs) JLI 150101 + D COV^%ut1(NMSP,COVCODE,+$G(VERBOSITY)) ; see COV^%ut1 for description of arguments + Q + ; +MULTAPIS(TESTROUS) ; .SR - RUN TESTS FOR SPECIFIED ROUTINES AND ENTRY POINTS + ; input - TESTROUS - passed by reference + ; see TESTONLY in routine %utcover for full description of TESTROUS argument + D MULTAPIS^%utcover(.TESTROUS) ; RUN TESTS FOR SPECIFIED ROUTINES AND ENTRY POINTS + Q + ; +COVERAGE(ROUNMSP,TESTROUS,XCLDROUS,RESLTLVL) ;.SR - run coverage analysis for multiple routines and entry points + ; input ROUNMSP + ; input TESTROUS - passed by reference + ; input XCLDROUS - passed by reference + ; input RESLTLVL + ; see COVERAGE in routine %utcover for full description of arguments + D COVERAGE^%utcover(ROUNMSP,.TESTROUS,.XCLDROUS,+$G(RESLTLVL)) + Q + ; +GETUTVAL(UTDATA) ; .SR - returns totals for current unit test data in cumulative totals + ; usage D GETUTVAL^%ut(.UTDATA) + ; input - UTDATA - passed by reference + ; + ; subscripted values returned: + ; 1) cumulative number of routines run; 2) cumulative number of entry tags; + ; 3) cumulative number of tests; 4) cummulative number of failures; + ; 5) cumulative number of errors + N VALS,I,VAL + S VALS=$G(^TMP("%ut",$J,"UTVALS")) I VALS="" Q + F I=1:1 S VAL=$P(VALS,U,I) Q:VAL="" S UTDATA(I)=$G(UTDATA(I))+VAL + K ^TMP("%ut",$J,"UTVALS") + Q + ; +LSTUTVAL(UTDATA) ; .SR - lists cumulative totals in UTDATA array + ; usage D LSTUTVAL^%ut(.UTDATA) + ; input - UTDATA - passed by reference + W !!!,"------------ SUMMARY ------------" + W !,"Ran ",UTDATA(1)," Routine",$S(UTDATA(1)>1:"s",1:""),", ",UTDATA(2)," Entry Tag",$S(UTDATA(2)>1:"s",1:"") + W !,"Checked ",UTDATA(3)," test",$S(UTDATA(3)>1:"s",1:""),", with ",UTDATA(4)," failure",$S(UTDATA(4)'=1:"s",1:"")," and encountered ",UTDATA(5)," error",$S(UTDATA(5)'=1:"s",1:""),"." + Q + ; + ; +GUISET(%utRSLT,XTSET) ; Entry point for GUI start with selected Test Set IEN - called by %ut-TEST GROUP LOAD rpc + N %utROU,%utLIST,%ut + D SETUT + S %ut("RSLT")=$NA(^TMP("MUNIT-%utRSLT",$J)) K @%ut("RSLT") + D GETSET(XTSET,.%utROU,.%utLIST) + D GETLIST(.%utROU,%utLIST,%ut("RSLT")) + S @%ut("RSLT")@(1)=(@%ut("RSLT")@(1))_"^1" ; 110719 mark as new version + S %utRSLT=%ut("RSLT") + Q + ; +GUILOAD(%utRSLT,%utROUN) ; Entry point for GUI start with %utROUN containing primary routine name - called by %ut-TEST LOAD rpc + N %utROU,%ut + D SETUT + S %ut("RSLT")=$NA(^TMP("MUNIT-%utRSLT",$J)) K @%ut("RSLT") + S %utROU(1)=%utROUN + D GETLIST(.%utROU,1,%ut("RSLT")) + S @%ut("RSLT")@(1)=(@%ut("RSLT")@(1))_"^1" ; 110719 mark as new version + S %utRSLT=%ut("RSLT") + Q + ; +GETLIST(%utROU,%utLIST,%utRSLT) ; called from GUISET, GUILOAD + N I,%utROUL,%utROUN,%ut,XTCOMNT,XTVALUE,%utCNT + S XTVALUE=$NA(^TMP("GUI-MUNIT",$J)) K @XTVALUE + S %utCNT=0,XTCOMNT="" + D GETTREE^%ut1(.%utROU,%utLIST) + F I=1:1 Q:'$D(%utROU(I)) S %utROUL(%utROU(I))="" + S %utROUN="" F S %utROUN=$O(%utROUL(%utROUN)) Q:%utROUN="" D LOAD(%utROUN,.%utCNT,XTVALUE,XTCOMNT,.%utROUL) + M @%utRSLT=@XTVALUE + K @%utRSLT@("SHUTDOWN") + K @%utRSLT@("STARTUP") + S @XTVALUE@("LASTROU")="" ; Use this to keep track of place in routines + Q + ; + ; generate list of unit test routines, entry points and comments on test for entry point +LOAD(%utROUN,%utNCNT,XTVALUE,XTCOMNT,%utROUL) ; called from GETLIST, and recursively from LOAD + I $T(@("^"_%utROUN))="" S %utNCNT=%utNCNT+1,@XTVALUE@(%utNCNT)=%utROUN_"^^*** ERROR - ROUTINE NAME NOT FOUND" Q + S %utNCNT=%utNCNT+1,@XTVALUE@(%utNCNT)=%utROUN_U_U_XTCOMNT + ;N %utI,XTX1,XTX2,LINE + N %utI,XTX1,XTX2,LINE,LIST,I + ; 100622 JLI added code to identify STARTUP and TEARDOWN + I $T(@("STARTUP^"_%utROUN))'="",'$D(@XTVALUE@("STARTUP")) S @XTVALUE@("STARTUP")="STARTUP^"_%utROUN + I $T(@("SHUTDOWN^"_%utROUN))'="",'$D(@XTVALUE@("SHUTDOWN")) S @XTVALUE@("SHUTDOWN")="SHUTDOWN^"_%utROUN + ; JLI 140731 handle @TEST identified test tags + D NEWSTYLE^%ut1(.LIST,%utROUN) + F I=1:1:LIST S %utNCNT=%utNCNT+1,@XTVALUE@(%utNCNT)=%utROUN_U_LIST(I) + ; JLI 140731 end of @TEST addition + F %utI=1:1 S LINE=$T(@("XTENT+"_%utI_"^"_%utROUN)) S XTX1=$P(LINE,";",3) Q:XTX1="" S XTX2=$P(LINE,";",4),%utNCNT=%utNCNT+1,@XTVALUE@(%utNCNT)=%utROUN_U_XTX1_U_XTX2 + F %utI=1:1 S LINE=$T(@("XTROU+"_%utI_"^"_%utROUN)) S XTX1=$P(LINE,";",3) Q:XTX1="" S XTCOMNT=$P(LINE,";",4) I '$D(%utROUL(XTX1)) S %utROUL(XTX1)="" D LOAD(XTX1,.%utNCNT,XTVALUE,XTCOMNT,.%utROUL) + Q + ; +GUINEXT(%utRSLT,%utLOC,XTGUISEP) ; Entry point for GUI execute next test - called by %ut-TEST NEXT rpc + ; XTGUISEP - added 110719 to provide for changing separator for GUI + ; return from ^ to another value ~~^~~ so that data returned + ; is not affected by ^ values in the data - if not present + ; sets value to default ^ + N %utETRY,%utROUT,XTOLROU,XTVALUE,%utERR,%utGUI + N %ut + I $G(XTGUISEP)="" S XTGUISEP="^" + D SETUT + S %ut("LOC")=%utLOC + S %ut("CURR")=0,%ut("ECNT")=0,%ut("FAIL")=0,%ut("CHK")=0,%ut("NENT")=0,%ut("ERRN")=0 + S XTVALUE=$NA(^TMP("GUI-MUNIT",$J)) + S %ut("RSLT")=$NA(^TMP("GUINEXT",$J)) K @%ut("RSLT") + S %utRSLT=%ut("RSLT") + S %utETRY=$P(%utLOC,U),%utROUT=$P(%utLOC,U,2),XTOLROU=$G(@XTVALUE@("LASTROU")) + S %utGUI=1 + S %ut("CHK")=0,%ut("CNT")=1,%utERR=0 + ; I %utROUT'=XTOLROU D I %utROUT="" S @%utRSLT@(1)="" K @XTVALUE Q ;140731 JLI - commented out + ;D I %utROUT="" S @%utRSLT@(1)="" K @XTVALUE Q ; 140731 JLI - replaced previous line - moves check for SHUTDOWN at end of processing + D I %utROUT="" S @%utRSLT@(1)="" Q ; 141018 JLI - Have to leave XTVALUE intact, in case they simply run again for STARTUP, etc. + . I XTOLROU="",$D(@XTVALUE@("STARTUP")) D + . . S %ut("LOC")=@XTVALUE@("STARTUP") + . . N $ETRAP S $ETRAP="D ERROR^%ut" + . . D @(@XTVALUE@("STARTUP")) + . . Q + . S @XTVALUE@("LASTROU")=%utROUT I %utROUT'="",$T(@("SETUP^"_%utROUT))'="" D + . . S %ut("LOC")="SETUP^"_%utROUT + . . N $ETRAP S $ETRAP="D ERROR^%ut" + . . D @("SETUP^"_%utROUT) + . . Q + . I %utROUT="",$D(@XTVALUE@("SHUTDOWN")) D + . . S %ut("LOC")=@XTVALUE@("SHUTDOWN") + . . N $ETRAP S $ETRAP="D ERROR^%ut" + . . D @(@XTVALUE@("SHUTDOWN")) + . . Q + . Q + S %ut("LOC")=%utLOC + S %ut("CHK")=0,%ut("CNT")=1,%utERR=0 + D ; to limit range of error trap so we continue through other tests + . N $ETRAP S $ETRAP="D ERROR^%ut" + . D @%ut("LOC") + . Q + I $T(@("TEARDOWN^"_%utROUT))'="" D + . S %ut("LOC")="TEARDOWN^"_%utROUT + . N $ETRAP S $ETRAP="D ERROR^%ut" + . D @("TEARDOWN^"_%utROUT) + . Q + S @%ut("RSLT")@(1)=%ut("CHK")_XTGUISEP_(%ut("CNT")-1-%utERR)_XTGUISEP_%utERR + K ^TMP("%ut",$J,"UTVALS") + Q + ; diff --git a/_ut1.m b/_ut1.m new file mode 100644 index 0000000..1325dc6 --- /dev/null +++ b/_ut1.m @@ -0,0 +1,433 @@ +%ut1 ;VEN/SMH/JLI - CONTINUATION OF M-UNIT PROCESSING ;04/08/16 20:36 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Joel L. Ivey as XTMUNIT1 while working for U.S. Department of Veterans Affairs 2003-2012 + ; Includes addition of original COV entry and code related coverage analysis as well as other substantial additions authored by Sam Habiel 07/2013?04/2014 + ; Additions and modifications made by Joel L. Ivey 05/2014-12/2015 + ; Additions and modifications made by Sam H. Habiel and Joel L. Ivey 02/2016-04/2016 + ; + ; comments moved to %utcover due to space requirements + D ^%utt6 ; runs unit tests from several perspectives + Q + ; + ;following is original header from XTMUNIT1 in unreleased patch XT*7.3*81 VA code + ;XTMUNIT1 ;JLI/FO-OAK-CONTINUATION OF UNIT TEST ROUTINE ;2014-04-17 5:26 PM + ;;7.3;TOOLKIT;**81**;APR 25 1995;Build 24 + ; + ; + ; Original by Dr. Joel Ivey + ; Major contributions by Dr. Sam Habiel + ; + ; +CHEKTEST(%utROU,%ut,%utUETRY) ; Collect Test list. + ; %utROU - input - Name of routine to check for tags with @TEST attribute + ; %ut - input/output - passed by reference + ; %utUETRY - input/output - passed by reference + ; + ; Test list collected in two ways: + ; - @TEST on labellines + ; - Offsets of XTENT + ; + S %ut("ENTN")=0 ; Number of test, sub to %utUETRY. + ; + ; This stanza and everything below is for collecting @TEST. + ; VEN/SMH - block refactored to use $TEXT instead of ^%ZOSF("LOAD") + N I,LIST + S I=$L($T(@(U_%utROU))) I I<0 Q "-1^Invalid Routine Name" + D NEWSTYLE(.LIST,%utROU) + F I=1:1:LIST S %ut("ENTN")=%ut("ENTN")+1,%utUETRY(%ut("ENTN"))=$P(LIST(I),U),%utUETRY(%ut("ENTN"),"NAME")=$P(LIST(I),U,2,99) + ; + ; This Stanza is to collect XTENT offsets + N %utUI F %utUI=1:1 S %ut("ELIN")=$T(@("XTENT+"_%utUI_"^"_%utROU)) Q:$P(%ut("ELIN"),";",3)="" D + . S %ut("ENTN")=%ut("ENTN")+1,%utUETRY(%ut("ENTN"))=$P(%ut("ELIN"),";",3),%utUETRY(%ut("ENTN"),"NAME")=$P(%ut("ELIN"),";",4) + . Q + ; + QUIT + ; + ; VEN/SMH 26JUL2013 - Moved GETTREE here. +GETTREE(%utROU,%utULIST) ; + ; first get any other routines this one references for running subsequently + ; then any that they refer to as well + ; this builds a tree of all routines referred to by any routine including each only once + N %utUK,%utUI,%utUJ,%utURNAM,%utURLIN + F %utUK=1:1 Q:'$D(%utROU(%utUK)) D + . F %utUI=1:1 S %utURLIN=$T(@("XTROU+"_%utUI_"^"_%utROU(%utUK))) S %utURNAM=$P(%utURLIN,";",3) Q:%utURNAM="" D + . . F %utUJ=1:1:%utULIST I %utROU(%utUJ)=%utURNAM S %utURNAM="" Q + . . I %utURNAM'="",$T(@("+1^"_%utURNAM))="" W:'$D(XWBOS) "Referenced routine ",%utURNAM," not found.",! Q + . . S:%utURNAM'="" %utULIST=%utULIST+1,%utROU(%utULIST)=%utURNAM + QUIT + ; +NEWSTYLE(LIST,ROUNAME) ; JLI 140726 identify and return list of newstyle tags or entries for this routine + ; LIST - input, passed by reference - returns containing array with list of tags identified as tests + ; LIST indicates number of tags identified, LIST(n)=tag^test_info where tag is entry point for test + ; ROUNAME - input - routine name in which tests should be identified + ; + N I,VALUE,LINE + K LIST S LIST=0 + ; search routine by line for a tag and @TEST declaration + F I=1:1 S LINE=$T(@("+"_I_"^"_ROUNAME)) Q:LINE="" S VALUE=$$CHECKTAG(LINE) I VALUE'="" S LIST=LIST+1,LIST(LIST)=VALUE + Q + ; +CHECKTAG(LINE) ; JLI 140726 check line to determine @test TAG + ; LINE - input - Line of code to be checked + ; returns null line if not @TEST line, otherwise TAG^NOTE + N TAG,NOTE,CHAR + I $E(LINE)=" " Q "" ; test entry must have a tag + I $$UP(LINE)'["@TEST" Q "" ; must have @TEST declaration + I $P($$UP(LINE),"@TEST")["(" Q "" ; can't have an argument + S TAG=$P(LINE," "),LINE=$P(LINE," ",2,400),NOTE=$P($$UP(LINE),"@TEST"),LINE=$E(LINE,$L(NOTE)+5+1,$L(LINE)) + F Q:NOTE="" S CHAR=$E(NOTE),NOTE=$E(NOTE,2,$L(NOTE)) I " ;"'[CHAR Q ; + I $L(NOTE)'=0 Q "" ; @TEST must be first text on line + F Q:$E(LINE)'=" " S LINE=$E(LINE,2,$L(LINE)) ; remove leading spaces from test info + S TAG=TAG_U_LINE + Q TAG + ; +FAIL(XTERMSG) ; Entry point for generating a failure message + ; ZEXCEPT: %utERRL,%utGUI -CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: %ut -- NEWED ON ENTRY + ; ZEXCEPT: XTGUISEP - newed in GUINEXT + I $G(XTERMSG)="" S XTERMSG="no failure message provided" + S %ut("CHK")=%ut("CHK")+1 + I '$D(%utGUI) D + . D SETIO + . W !,%ut("ENT")," - " W:%ut("NAME")'="" %ut("NAME")," - " W XTERMSG,! D + . . S %ut("FAIL")=%ut("FAIL")+1,%utERRL(%ut("FAIL"))=%ut("NAME"),%utERRL(%ut("FAIL"),"MSG")=XTERMSG,%utERRL(%ut("FAIL"),"ENTRY")=%ut("ENT") + . . I $D(%ut("BREAK")) BREAK ; Break upon failure + . . Q + . D RESETIO + . Q + I $D(%utGUI) S %ut("CNT")=%ut("CNT")+1,@%ut("RSLT")@(%ut("CNT"))=%ut("LOC")_XTGUISEP_"FAILURE"_XTGUISEP_XTERMSG,%ut("FAIL")=%ut("FAIL")+1 + Q + ; +NVLDARG(API) ; generate message for invalid arguments to test + N XTERMSG + ; ZEXCEPT: %ut -- NEWED ON ENTRY + ; ZEXCEPT: %utERRL,%utGUI -CREATED IN SETUP, KILLED IN END + ; ZEXCEPT: XTGUISEP - newed in GUINEXT + S XTERMSG="NO VALUES INPUT TO "_API_"^%ut - no evaluation possible" + I '$D(%utGUI) D + . D SETIO + . W !,%ut("ENT")," - " W:%ut("NAME")'="" %ut("NAME")," - " W XTERMSG,! D + . . S %ut("FAIL")=%ut("FAIL")+1,%utERRL(%ut("FAIL"))=%ut("NAME"),%utERRL(%ut("FAIL"),"MSG")=XTERMSG,%utERRL(%ut("FAIL"),"ENTRY")=%ut("ENT") + . . Q + . D RESETIO + . Q + I $D(%utGUI) S %ut("CNT")=%ut("CNT")+1,@%ut("RSLT")@(%ut("CNT"))=%ut("LOC")_XTGUISEP_"FAILURE"_XTGUISEP_XTERMSG,%ut("FAIL")=%ut("FAIL")+1 + Q + ; +SETIO ; Set M-Unit Device to write the results to... + ; ZEXCEPT: %ut -- NEWED ON ENTRY + I $IO'=%ut("IO") S (IO(0),%ut("DEV","OLD"))=$IO USE %ut("IO") SET IO=$IO + QUIT + ; +RESETIO ; Reset $IO back to the original device if we changed it. + ; ZEXCEPT: %ut -- NEWED ON ENTRY + I $D(%ut("DEV","OLD")) S IO(0)=%ut("IO") U %ut("DEV","OLD") S IO=$IO K %ut("DEV","OLD") + QUIT + ; + ; VEN/SMH 17DEC2013 - Remove dependence on VISTA - Uppercase here instead of XLFSTR. +UP(X) ; + Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ") + ; +COV(NMSP,COVCODE,VERBOSITY) ; VEN/SMH - PUBLIC ENTRY POINT; Coverage calculations + ; NMSP: Namespace of the routines to analyze. End with * to include all routines. + ; Not using * will only include the routine with NMSP name. + ; e.g. PSOM* will include all routines starting with PSOM + ; PSOM will only include PSOM. + ; COVCODE: Mumps code to run over which coverage will be calculated. Typically Unit Tests. + ; VERBOSITY (optional): Scalar from -1 to 3. + ; - -1 = Global output in ^TMP("%utCOVREPORT",$J) + ; - 0 = Print only total coverage + ; - 1 = Break down by routine + ; - 2 = Break down by routine and tag + ; - 3 = Break down by routine and tag, and print lines that didn't execute for each tag. + ; + ; ZEXCEPT: %utcovxx - SET and KILLED in this code at top level + ; ZEXCEPT: %Monitor,%apiOBJ,DecomposeStatus,LineByLine,Start,Stop,System,class - not variables parts of classes + N COVER,COVERSAV,I,NMSP1,RTN,RTNS,ERR,STATUS + I (+$SY=47) D ; GT.M only! + . N %ZR ; GT.M specific + . D SILENT^%RSEL(NMSP,"SRC") ; GT.M specific. On Cache use $O(^$R(RTN)). + . N RN S RN="" + . W !,"Loading routines to test coverage...",! + . F S RN=$O(%ZR(RN)) Q:RN="" W RN," " D + . . N L2 S L2=$T(+2^@RN) + . . ;S L2=$TR(L2,$C(9,32)) ; Translate spaces and tabs out ; JLI 160316 commented out + . . S L2=$TR(L2,$C(9)," ") ; change tabs to spaces ; JLI 160316 inserted to replace above + . . ;I $E(L2,1,2)'=";;" K %ZR(RN) ; Not a human produced routine JLI 160316 commented out + . . ; routine doesn't follow the standards and second line start with ;; ; JLI 160316 + . . I $E($P(L2," ",2),1,2)'=";;" K %ZR(RN) W !,"Routine "_RN_" removed from analysis, since it doesn't have the standard second line" ; JLI 160316 inserted to replace above + . ; + . M RTNS=%ZR + . K %ZR + . Q + ; + I (+$SY=0) D ; CACHE SPECIFIC + . S NMSP1=NMSP I NMSP["*" S NMSP1=$P(NMSP,"*") + . I $D(^$R(NMSP1)) S RTNS(NMSP1)="" + . I NMSP["*" S RTN=NMSP1 F S RTN=$O(^$R(RTN)) Q:RTN'[NMSP1 S RTNS(RTN)="" + . Q + ; + ; ZEXCEPT: CTRAP - not really a variable + S VERBOSITY=+$G(VERBOSITY) ; Get 0 if not passed. + ; + ; + N GL + S GL=$NA(^TMP("%utCOVCOHORT",$J)) + I '$D(^TMP("%utcovrunning",$J)) K @GL + D RTNANAL(.RTNS,GL) ; save off any current coverage data + I '$D(^TMP("%utcovrunning",$J)) N EXIT S EXIT=0 D Q:EXIT + . K ^TMP("%utCOVCOHORTSAV",$J) + . M ^TMP("%utCOVCOHORTSAV",$J)=^TMP("%utCOVCOHORT",$J) + . K ^TMP("%utCOVRESULT",$J) + . S ^TMP("%utcovrunning",$J)=1,%utcovxx=1 + . ; + . I (+$SY=47) VIEW "TRACE":1:$NA(^TMP("%utCOVRESULT",$J)) ; GT.M START PROFILING + . ; + . I (+$SY=0) D ; CACHE CODE TO START PROFILING + . . S STATUS=##class(%Monitor.System.LineByLine).Start($lb(NMSP),$lb("RtnLine"),$lb($j)) + . . I +STATUS'=1 D DecomposeStatus^%apiOBJ(STATUS,.ERR,"-d") F I=1:1:ERR W ERR(I),! + . . I +STATUS'=1 K ERR S EXIT=1 + . . Q + . Q + DO ; Run the code, but keep our variables to ourselves. + . NEW $ETRAP,$ESTACK + . I (+$SY=47) D ; GT.M SPECIFIC + . . SET $ETRAP="Q:($ES&$Q) -9 Q:$ES W ""CTRL-C ENTERED""" + . . USE $PRINCIPAL:(CTRAP=$C(3)) + . . Q + . NEW (DUZ,IO,COVCODE,U,DILOCKTM,DISYS,DT,DTIME,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY) + . XECUTE COVCODE + . Q + ; GT.M STOP PROFILING if this is the original level that started it + I $D(^TMP("%utcovrunning",$J)),$D(%utcovxx) D + . I (+$SY=47) VIEW "TRACE":0:$NA(^TMP("%utCOVRESULT",$J)) ; GT.M SPECIFIC + . I (+$SY=0) ; CACHE SPECIFIC + . K %utcovxx,^TMP("%utcovrunning",$J) + . Q + ; + I '$D(^TMP("%utcovrunning",$J)) D + . I (+$SY=0) D ; CACHE SPECIFIC CODE + . . S COVERSAV=$NA(^TMP("%utCOVCOHORTSAV",$J)) K @COVERSAV + . . S COVER=$NA(^TMP("%utCOVCOHORT",$J)) K @COVER + . . D CACHECOV(COVERSAV,COVER) + . . D TOTAGS(COVERSAV,0),TOTAGS(COVER,1) + . . D ##class(%Monitor.System.LineByLine).Stop() + . . Q + . D COVCOV($NA(^TMP("%utCOVCOHORT",$J)),$NA(^TMP("%utCOVRESULT",$J))) ; Venn diagram matching between globals + . ; Report + . I VERBOSITY=-1 D + . . K ^TMP("%utCOVREPORT",$J) + . . D COVRPTGL($NA(^TMP("%utCOVCOHORTSAV",$J)),$NA(^TMP("%utCOVCOHORT",$J)),$NA(^TMP("%utCOVRESULT",$J)),$NA(^TMP("%utCOVREPORT",$J))) + . . Q + . E D COVRPT($NA(^TMP("%utCOVCOHORTSAV",$J)),$NA(^TMP("%utCOVCOHORT",$J)),$NA(^TMP("%utCOVRESULT",$J)),VERBOSITY) + . Q + QUIT + ; +CACHECOV(GLOBSAV,GLOB) ; + ; ZEXCEPT: %Monitor,GetMetrics,GetRoutineCount,GetRoutineName,LineByLine,System,class - not variable names, part of classes + N DIF,I,METRIC,METRICNT,METRICS,MTRICNUM,ROUNAME,ROUNUM,X,XCNP,XXX + I $$ISUTEST(),'$D(^TMP("%utt4val",$J)) S ROUNUM=1,METRICS="RtnLine",METRICNT=1,ROUNAME="%ut" + I $D(^TMP("%utt4val",$J))!'$$ISUTEST() S ROUNUM=##class(%Monitor.System.LineByLine).GetRoutineCount(),METRICS=##class(%Monitor.System.LineByLine).GetMetrics(),METRICNT=$l(METRICS,",") + ; if only running to do coverage, should be 1 + S MTRICNUM=0 F I=1:1:METRICNT S METRIC=$P(METRICS,",",I) I METRIC="RtnLine" S MTRICNUM=I Q + ; + F I=1:1:ROUNUM D + . I $D(^TMP("%utt4val",$J))!'$$ISUTEST() S ROUNAME=##class(%Monitor.System.LineByLine).GetRoutineName(I) + . ; get routine loaded into location + . S DIF=$NA(@GLOBSAV@(ROUNAME)),DIF=$E(DIF,1,$L(DIF)-1)_",",XCNP=0,X=ROUNAME + . I $D(^%ZOSF("LOAD")) X ^%ZOSF("LOAD") + . E X "N %,%N S %N=0 X ""ZL @X F XCNP=XCNP+1:1 S %N=%N+1,%=$T(+%N) Q:$L(%)=0 S @(DIF_XCNP_"""",0)"""")=%""" + . M @GLOB@(ROUNAME)=@GLOBSAV@(ROUNAME) + . Q + ; + I $D(^TMP("%utt4val",$J))!'$$ISUTEST() F XXX=1:1:ROUNUM D GETVALS(XXX,GLOB,MTRICNUM) + Q + ; +GETVALS(ROUNUM,GLOB,MTRICNUM) ; get data on number of times a line seen (set into VAL) + ; ZEXCEPT: %Monitor,%New,%ResultSet,Execute,GetData,GetRoutineName,LineByLine,Next,System,class - not variables parts of Cache classes + N LINE,MORE,ROUNAME,RSET,VAL,X + ; + S RSET=##class(%ResultSet).%New("%Monitor.System.LineByLine:Result") + S ROUNAME=##class(%Monitor.System.LineByLine).GetRoutineName(ROUNUM) + S LINE=RSET.Execute(ROUNAME) + F LINE=1:1 S MORE=RSET.Next() Q:'MORE D + . S X=RSET.GetData(1) + . S VAL=$LI(X,MTRICNUM) + . S @GLOB@(ROUNAME,LINE,"C")=+VAL ; values are 0 if not seen, otherwise positive number + . Q + D RSET.Close() + Q + ; +TOTAGS(GLOBAL,ACTIVE) ; convert to lines from tags and set value only if not seen + N ACTIVCOD,LINE,LINENUM,ROU,ROUCODE + S ROU="" F S ROU=$O(@GLOBAL@(ROU)) Q:ROU="" D + . M ROUCODE(ROU)=@GLOBAL@(ROU) K @GLOBAL@(ROU) + . N TAG,OFFSET,OLDTAG S TAG="",OFFSET=0,OLDTAG="" + . F LINENUM=1:1 Q:'$D(ROUCODE(ROU,LINENUM,0)) D + . . S LINE=ROUCODE(ROU,LINENUM,0) + . . S ACTIVCOD=$$LINEDATA(LINE,.TAG,.OFFSET) + . . I TAG'=OLDTAG S @GLOBAL@(ROU,TAG)=TAG + . . I ACTIVE,ACTIVCOD,(+$G(ROUCODE(ROU,LINENUM,"C"))'>0) S @GLOBAL@(ROU,TAG,OFFSET)=LINE + . . I 'ACTIVE,ACTIVCOD S @GLOBAL@(ROU,TAG,OFFSET)=LINE + . . Q + . Q + Q + ; +LINEDATA(LINE,TAG,OFFSET) ; + ; LINE - input - the line of code + ; TAG - passed by reference - + ; OFFSET - passed by reference + N CODE,NEWTAG + S NEWTAG="" + S OFFSET=$G(OFFSET)+1 + F Q:$E(LINE,1)=" " Q:$E(LINE,1)=$C(9) Q:LINE="" S NEWTAG=NEWTAG_$E(LINE,1),LINE=$E(LINE,2,$L(LINE)) + S NEWTAG=$P(NEWTAG,"(") + I NEWTAG'="" S TAG=NEWTAG,OFFSET=0 + S CODE=1 + F S:(LINE="")!($E(LINE)=";") CODE=0 Q:'CODE Q:(" ."'[$E(LINE)) S LINE=$E(LINE,2,$L(LINE)) + Q CODE + ; +RTNANAL(RTNS,GL) ; [Private] - Routine Analysis + ; Create a global similar to the trace global produced by GT.M in GL + ; Only non-comment lines are stored. + ; A tag is always stored. Tag,0 is stored only if there is code on the tag line (format list or actual code). + ; tags by themselves don't count toward the total. + ; + N RTN S RTN="" + F S RTN=$O(RTNS(RTN)) Q:RTN="" D ; for each routine + . N TAG,LN,T + . ; S TAG=RTN ; start the tags at the first ; JLI 160316 commented out + . S LN=$T(+1^@RTN) + . S TAG=$$GETTAG(.T,LN) ; JLI 160316 - don't assume first line tag is routine name + . N I F I=2:1 S LN=$T(@TAG+I^@RTN) Q:LN="" D ; for each line, starting with the 3rd line (2 off the first tag) + . . I $E(LN)?1A D QUIT ; formal line + . . . ;N T ; Terminator + . . . ;N J F J=1:1:$L(LN) S T=$E(LN,J) Q:T'?1AN ; Loop to... + . . . ;S TAG=$E(LN,1,J-1) ; Get tag + . . . S TAG=$$GETTAG(.T,LN) ; JLI 160316 - replace above commented out lines + . . . S @GL@(RTN,TAG)=TAG ; store line + . . . ;I T="(" S @GL@(RTN,TAG,0)=LN ; formal list + . . . I T="(" D ; formal list + . . . . ;N PCNT,STR,CHR S PCNT=0,STR=$E(LN,J+1,$L(LN)) + . . . . N PCNT,STR,CHR S PCNT=0,STR=$P(LN,"(",2,99) + . . . . F S CHR=$E(STR),STR=$E(STR,2,$L(STR)) Q:(PCNT=0)&(CHR=")") D + . . . . . I CHR="(" S PCNT=PCNT+1 + . . . . . I CHR=")" S PCNT=PCNT-1 + . . . . . Q + . . . . S STR=$TR(STR,$C(9,32)) + . . . . I $E(STR)=";" QUIT ; comment line - no code + . . . . S @GL@(RTN,TAG,0)=LN + . . . . Q + . . . E D ; No formal list + . . . . N LNTR S LNTR=$P(LN,TAG,2,999),LNTR=$TR(LNTR,$C(9,32)) ; Get rest of line, Remove spaces and tabs + . . . . I $E(LNTR)=";" QUIT ; Comment + . . . . S @GL@(RTN,TAG,0)=LN ; Otherwise, store for testing + . . . S I=0 ; Start offsets from zero (first one at the for will be 1) + . . I $C(32,9)[$E(LN) D QUIT ; Regular line + . . . N LNTR S LNTR=$TR(LN,$C(32,9,46)) ; Remove all spaces and tabs - JLI 150202 remove periods as well + . . . I $E(LNTR)=";" QUIT ; Comment line -- don't want. + . . . S @GL@(RTN,TAG,I)=LN ; Record line + QUIT + ; +GETTAG(TERMINTR,LN) ;.EF - get TAG for line, if any + ; TERMINTR - passed by reference - contains terminator of tag on return + ; LN - input - text of line + N J,TAG + F J=1:1:$L(LN) S TERMINTR=$E(LN,J) Q:(TERMINTR'?1AN)&((J'=1)&(TERMINTR'="%")) ; Loop to... + S TAG=$E(LN,1,J-1) ; Get tag + Q TAG + ; +ACTLINES(GL) ; [Private] $$ ; Count active lines + ; + N CNT S CNT=0 + N REF S REF=GL + N GLQL S GLQL=$QL(GL) + F S REF=$Q(@REF) Q:REF="" Q:(GL'=$NA(@REF,GLQL)) D + . N REFQL S REFQL=$QL(REF) + . N LASTSUB S LASTSUB=$QS(REF,REFQL) + . ;I LASTSUB?1.N S CNT=CNT+1 ; JLI 160315 commented out + . ; count only those with tag,number - not tags which are numbers only ; JLI 160315 + . I (LASTSUB?1.N)&($QL(REF)=5) S CNT=CNT+1 ; JLI 160315 replaces commented out line + QUIT CNT + ; +COVCOV(C,R) ; [Private] - Analyze coverage Cohort vs Result + N RTN S RTN="" + F S RTN=$O(@C@(RTN)) Q:RTN="" D ; For each routine in cohort set + . I '$D(@R@(RTN)) QUIT ; Not present in result set + . N TAG S TAG="" + . F S TAG=$O(@R@(RTN,TAG)) Q:TAG="" D ; For each tag in the routine in the result set + . . N LN S LN="" + . . F S LN=$O(@R@(RTN,TAG,LN)) Q:LN="" D ; for each line in the tag in the routine in the result set + . . . I $D(@C@(RTN,TAG,LN)) K ^(LN) ; if present in cohort, kill off + QUIT + ; +COVRPT(C,S,R,V) ; [Private] - Coverage Report + ; C = COHORT - Global name + ; S = SURVIVORS - Global name + ; R = RESULT - Global name + ; V = Verbosity - Scalar from -1 to 3 + ; JLI 150702 - modified to be able to do unit tests on setting up the text via COVRPTLS + N X,I + S X=$NA(^TMP("%ut1-covrpt",$J)) K @X + D COVRPTLS(C,S,R,V,X) + I '$$ISUTEST^%ut() F I=1:1 W:$D(@X@(I)) !,@X@(I) I '$D(@X@(I)) K @X Q + Q + ; +COVRPTLS(C,S,R,V,X) ; + ; + N LINNUM S LINNUM=0 + N ORIGLINES S ORIGLINES=$$ACTLINES(C) + N LEFTLINES S LEFTLINES=$$ACTLINES(S) + S LINNUM=LINNUM+1,@X@(LINNUM)="",LINNUM=LINNUM+1,@X@(LINNUM)="" + S LINNUM=LINNUM+1,@X@(LINNUM)="ORIG: "_ORIGLINES + S LINNUM=LINNUM+1,@X@(LINNUM)="LEFT: "_LEFTLINES + S LINNUM=LINNUM+1,@X@(LINNUM)="COVERAGE PERCENTAGE: "_$S(ORIGLINES:$J((ORIGLINES-LEFTLINES)/ORIGLINES*100,"",2),1:100.00) + S LINNUM=LINNUM+1,@X@(LINNUM)="",LINNUM=LINNUM+1,@X@(LINNUM)="" + S LINNUM=LINNUM+1,@X@(LINNUM)="BY ROUTINE:" + I V=0 QUIT ; No verbosity. Don't print routine detail + N RTN S RTN="" + F S RTN=$O(@C@(RTN)) Q:RTN="" D + . N O S O=$$ACTLINES($NA(@C@(RTN))) + . N L S L=$$ACTLINES($NA(@S@(RTN))) + . N XX,XY S XX=" "_RTN_" ",XX=$E(XX,1,12) + . S XY=" "_$S(O:$J((O-L)/O*100,"",2)_"%",1:"------"),XY=$E(XY,$L(XY)-11,$L(XY)) + . I O>0 S LINNUM=LINNUM+1,@X@(LINNUM)=XX_XY_" "_(O-L)_" out of "_O + . I V=1 QUIT ; Just print the routine coverage for V=1 + . N TAG S TAG="" + . F S TAG=$O(@C@(RTN,TAG)) Q:TAG="" D + . . N O S O=$$ACTLINES($NA(@C@(RTN,TAG))) + . . N L S L=$$ACTLINES($NA(@S@(RTN,TAG))) + . . S XX=" "_TAG_" ",XX=$E(XX,1,20) + . . S XY=" "_$S(O:$J((O-L)/O*100,"",2)_"%",1:"------"),XY=$E(XY,$L(XY)-7,$L(XY)) + . . I O>0 S LINNUM=LINNUM+1,@X@(LINNUM)=XX_XY_" "_(O-L)_" out of "_O + . . I V=2 QUIT ; Just print routine/tags coverage for V=2; V=3 print uncovered lines + . . N LN S LN="" + . . F S LN=$O(@S@(RTN,TAG,LN)) Q:LN="" S LINNUM=LINNUM+1,@X@(LINNUM)=TAG_"+"_LN_": "_^(LN) + . . Q + . Q + QUIT + ; +COVRPTGL(C,S,R,OUT) ; [Private] - Coverage Global for silent invokers + ; C = COHORT - Global name + ; S = SURVIVORS - Global name + ; R = RESULT - Global name + ; OUT = OUTPUT - Global name + ; + N O S O=$$ACTLINES(C) + N L S L=$$ACTLINES(S) + S @OUT=(O-L)_"/"_O + N RTN,TAG,LN S (RTN,TAG,LN)="" + F S RTN=$O(@C@(RTN)) Q:RTN="" D + . N O S O=$$ACTLINES($NA(@C@(RTN))) + . N L S L=$$ACTLINES($NA(@S@(RTN))) + . S @OUT@(RTN)=(O-L)_"/"_O + . F S TAG=$O(@C@(RTN,TAG)) Q:TAG="" D + . . N O S O=$$ACTLINES($NA(@C@(RTN,TAG))) + . . N L S L=$$ACTLINES($NA(@S@(RTN,TAG))) + . . S @OUT@(RTN,TAG)=(O-L)_"/"_O + . . F S LN=$O(@S@(RTN,TAG,LN)) Q:LN="" S @OUT@(RTN,TAG,LN)=@S@(RTN,TAG,LN) + QUIT + ; +ISUTEST() ; + Q $$ISUTEST^%ut() diff --git a/_utcover.m b/_utcover.m new file mode 100644 index 0000000..1e0a4fd --- /dev/null +++ b/_utcover.m @@ -0,0 +1,211 @@ +%utcover ;JLI - generic coverage and unit test runner ;04/08/16 20:37 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Joel L. Ivey 08/15. Additional work 08/15-04/16. + ; + ; Changes: (Moved from %ut and %ut1) + ; 130726 SMH - Moved test collection logic from %utUNIT to here (multiple places) + ; 131218 SMH - dependence on XLFSTR removed + ; 131218 SMH - CHEKTEST refactored to use $TEXT instead of ^%ZOSF("LOAD") + ; 131218 SMH - CATCHERR now nulls out $ZS if on GT.M + ; + ; ------- COMMENTS moved from %ut due to space requirements + ; + ; 100622 JLI - corrected typo in comments where %utINPT was listed as %utINP + ; 100622 JLI - removed a comment which indicated data could potentially be returned from the called routine + ; in the %utINPT array. + ; 100622 JLI - added code to handle STARTUP and SHUTDOWN from GUI app + ; 110719 JLI - modified separators in GUI handling from ^ to ~~^~~ + ; in the variable XTGUISEP if using a newer version of the + ; GUI app (otherwise, it is simply set to ^) since results + ; with a series of ^ embedded disturbed the output reported + ; 130726 SMH - Fixed SETUP and TEARDOWN so that they run before/after each + ; test rather than once. General refactoring. + ; 130726 SMH - SETUT initialized IO in case it's not there to $P. Inits vars + ; using DT^DICRW. + ; 131217 SMH - Change call in SETUP to S U="^" instead of DT^DICRW + ; 131218 SMH - Any checks to $ZE will also check $ZS for GT.M. + ; 131218 SMH - Remove calls to %ZISUTL to manage devices to prevent dependence on VISTA. + ; Use %utNIT("DEV","OLD") for old devices + ; 140109 SMH - Add parameter %utBREAK - Break upon error + ; 1402 SMH - Break will cause the break to happen even on failed tests. + ; 140401 SMH - Added Succeed entry point for take it into your hands tester. + ; 140401 SMH - Reformatted the output of M-Unit so that the test's name + ; will print BEFORE the execution of the test. This has been + ; really confusing for beginning users of M-Unit, so this was + ; necessary. + ; 140401 SMH - OK message gets printed at the end of --- as [OK]. + ; 140401 SMH - FAIL message now prints. Previously, OK failed to be printed. + ; Unfortunately, that's rather passive aggressive. Now it + ; explicitly says that a test failed. + ; 140503 SMH - Fixed IO issues all over the routine. Much simpler now. + ; 140731 JLI - Combined routine changes between JLI and SMH + ; Moved routines from %utNIT and %utNIT1 to %ut and %ut1 + ; Updated unit test routines (%utt1 to %utt6) + ; Created M-UNIT TEST GROUP file at 17.9001 based on the 17.9001 file + ; 141030 JLI - Removed tag TESTCOVR and code under it, not necessary + ; since %uttcovr can handle all of the calling needed + ; Added call to run routine %utt6 if run from the top, + ; since this will run the full range of unit tests + ; Modified STARTUP and SHUTDOWN commands to handle in + ; each routine where they are available, since only + ; running one STARTUP and SHUTDOWN (the first seen by + ; the program) restricted their use in suites of multiple + ; tests. + ; 150101 JLI - Added COV entry to %ut (in addition to current in %ut1) so it is easier + ; to remember how to use it. + ; 150621 JLI - Added a global location to pick up summary data for a unit test call, so + ; programs running multiple calls can generate a summary if desired. + ; + ; + D EN^%ut("%uttcovr") ; unit tests + Q + ; +MULTAPIS(TESTROUS) ; RUN TESTS FOR SPECIFIED ROUTINES AND ENTRY POINTS + ; can be run from %ut using D MULTAPIS^%ut(.TESTROUS) + ; input TESTROUS - passed by reference - array of routine names to run tests for + ; specify those to be called directly by including ^ as part of + ; TAG^ROUTINE or ^ROUTINE. + ; ROUTINE names without a ^ will be called as EN^%ut("ROUTINE") + ; Sometimes to get complete coverage, different entry points may + ; need to be called (e.g., at top and for VERBOSE), these should each + ; be included. + ; If the subscript is a number, it will take the list of comma separated + ; values as the routines. If the the subscript is not a number, it will + ; take it as a routine to be added to the list, then if the value of the + ; contains a comma separated list of routines, they will be added as well. + ; Thus a value of + ; TESTROUS(1)="A^ROU1,^ROU1,^ROU2,ROU3" + ; or a value of + ; TESTROUS("A^ROU1")="^ROU1,^ROU2,ROU3" + ; will both result in tests for + ; D A^ROU1,^ROU1,^ROU2,EN^%ut("ROU3") + K ^TMP("%utcover",$J,"TESTROUS") + M ^TMP("%utcover",$J,"TESTROUS")=TESTROUS + D COVENTRY + K ^TMP("%utcover",$J,"TESTROUS") + Q + ; +COVENTRY ; setup of COVERAGE NEWs most variables, so TESTROUS passed by global + ; + ; CJE Add U + N I,ROU,VAL,VALS,UTDATA,TESTS,TESTROUS,U + S U="^" + M TESTROUS=^TMP("%utcover",$J,"TESTROUS") + S ROU="" F S ROU=$O(TESTROUS(ROU)) Q:ROU="" D + . I ROU'=+ROU S TESTS(ROU)="" + . F I=1:1 S VAL=$P(TESTROUS(ROU),",",I) Q:VAL="" S TESTS(VAL)="" + . Q + S ROU="" F S ROU=$O(TESTS(ROU)) Q:ROU="" D + . W !!,"------------------- RUNNING ",ROU," -------------------",! ; JLI 160319 put CR after line so periods start on new line + . I ROU[U D @ROU + . I ROU'[U D @("EN^%ut("""_ROU_""")") + . D GETUTVAL^%ut(.UTDATA) + . Q + I $D(UTDATA) D LSTUTVAL^%ut(.UTDATA) + Q + ; +COVERAGE(ROUNMSP,TESTROUS,XCLDROUS,RESLTLVL) ; run coverage analysis for multiple routines and entry points + ; can be run from %ut using D COVERAGE^%ut(ROUNMSP,.TESTROUS,.XCLDROUS,RESLTLVL) + ; input ROUNMSP - Namespace for routine(s) to be analyzed + ; ROUNAME will result in only the routine ROUNAME being analyzed + ; ROUN* will result in all routines beginning with ROUN being analyzed + ; input TESTROUS - passed by reference - see TESTROUS description for JUSTTEST + ; input XCLDROUS - passed by reference - routines passed in a manner similar to TESTROUS, + ; but only the routine names, whether as arguments or a comma separated + ; list of routines, will be excluded from the analysis of coverage. These + ; would normally be names of routines which are only for unit tests, or + ; others which should not be included in the analysis for some reason. + ; input RESLTLVL - This value determines the amount of information to be generated for the + ; analysis. A missing or null value will be considered to be level 1 + ; 1 - Listing of analysis only for routine overall + ; 2 - Listing of analysis for routine overall and for each TAG + ; 3 - Full analysis for each tag, and lists out those lines which were + ; not executed during the analysis + ; + N I,ROU,TYPE,XCLUDE + S RESLTLVL=$G(RESLTLVL,1) + I (RESLTLVL<1) S RESLTLVL=1 + I (RESLTLVL>3) S RESLTLVL=3 + M ^TMP("%utcover",$J,"TESTROUS")=TESTROUS ; + D COV^%ut1(ROUNMSP,"D COVENTRY^%utcover",-1) + K ^TMP("%utcover",$J,"TESTROUS") + S ROU="" F S ROU=$O(XCLDROUS(ROU)) Q:ROU="" D SETROUS(.XCLUDE,.XCLDROUS,ROU) + N TEXTGLOB S TEXTGLOB=$NA(^TMP("%utcover-text",$J)) K @TEXTGLOB + D LIST(.XCLUDE,RESLTLVL,TEXTGLOB) + F I=1:1 Q:'$D(@TEXTGLOB@(I)) W !,@TEXTGLOB@(I) + K @TEXTGLOB + Q + ; +SETROUS(XCLUDE,XCLDROUS,ROU) ; + ; XCLUDE - passed by reference - on return contains array with indices as routines to exclude from analysis + ; XCLDROUS - passed by referenc - array may contain a comma-delimited list of routines to exclude from analysis + ; ROU - input - if non-numberic is name of routine to exclude from analysis + N I,VAL + I ROU'=+ROU S XCLUDE(ROU)="" + F I=1:1 S VAL=$P(XCLDROUS(ROU),",",I) Q:VAL="" S XCLUDE(VAL)="" + Q + ; +LIST(XCLDROUS,TYPE,TEXTGLOB,GLOB,LINNUM) ; + ; ZEXCEPT: TYPE1 - NEWed and set below for recursion + ; input - ROULIST - a comma separated list of routine names that will + ; be used to identify desired routines. Any name + ; that begins with one of the specified values will + ; be included + ; input - TYPE - value indicating amount of detail desired + ; 3=full with listing of untouched lines + ; 2=moderated with listing by tags + ; 1=summary with listing by routine + ; input - TEXTGLOB - closed global location in which text is returned + ; input - GLOB - used for unit tests - specifies global to work with + ; so that coverage data is not impacted + ; + N CURRCOV,CURRLIN,LINCOV,LINE,LINTOT,ROULIST,ROUNAME,TAG,TOTCOV,TOTLIN,XVAL + ; + I '$D(LINNUM) S LINNUM=0 ; initialize on first entry + I '$D(GLOB) N GLOB S GLOB=$NA(^TMP("%utCOVREPORT",$J)) + D TRIMDATA(.XCLDROUS,GLOB) ; remove undesired routines from data + ; + N JOB,NAME,BASE,TEXT,VAL + S TOTCOV=0,TOTLIN=0 + ; F NAME="%utCOVREPORT","%utCOVRESULT","%utCOVCOHORT","%utCOVCOHORTSAV" D + I TYPE>1 S ROUNAME="" F S ROUNAME=$O(@GLOB@(ROUNAME)) Q:ROUNAME="" S XVAL=^(ROUNAME) D + . S CURRCOV=$P(XVAL,"/"),CURRLIN=$P(XVAL,"/",2) + . S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="",LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="" + . S TEXT="Routine "_ROUNAME_" ",TEXT=$E(TEXT,1,20) + . I CURRLIN>0 S VAL=" ("_$J((100*CURRCOV)/CURRLIN,"",2),VAL=$E(VAL,$L(VAL)-6,$L(VAL)) + . S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)=TEXT_" "_$S(CURRLIN>0:VAL_"%)",1:" ------ ")_" "_CURRCOV_" out of "_CURRLIN_" lines covered" + . I TYPE>1 S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)=" - "_$S(TYPE=2:"Summary",1:"Detailed Breakdown") + . S TAG="" F S TAG=$O(@GLOB@(ROUNAME,TAG)) Q:TAG="" S XVAL=^(TAG) D + . . S LINCOV=$P(XVAL,"/"),LINTOT=$P(XVAL,"/",2) + . . S TEXT=" Tag "_TAG_"^"_ROUNAME_" ",TEXT=$E(TEXT,1,26) + . . I LINTOT>0 S VAL=" ("_$J((100*LINCOV)/LINTOT,"",2),VAL=$E(VAL,$L(VAL)-6,$L(VAL)) + . . S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)=TEXT_$S(LINTOT>0:VAL_"%)",1:" ------ ")_" "_LINCOV_" out of "_LINTOT_" lines covered" + . . I TYPE=2 Q + . . I LINCOV=LINTOT Q + . . S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)=" the following is a list of the lines **NOT** covered" + . . S LINE="" F S LINE=$O(@GLOB@(ROUNAME,TAG,LINE)) Q:LINE="" D + . . . I LINE=0 S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)=" "_TAG_" "_@GLOB@(ROUNAME,TAG,LINE) Q + . . . S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)=" "_TAG_"+"_LINE_" "_@GLOB@(ROUNAME,TAG,LINE) + . . . Q + . . Q + . Q + ; for type=3 generate a summary at bottom after detail + I TYPE=3 N TYPE1 S TYPE1=2 D LIST(.XCLDROUS,2,TEXTGLOB,GLOB,.LINNUM) K TYPE1 + I TYPE=2,$G(TYPE1) Q ; CAME IN FROM ABOVE LINE + ; summarize by just routine name + S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="",LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="" + S ROUNAME="" F S ROUNAME=$O(@GLOB@(ROUNAME)) Q:ROUNAME="" S XVAL=^(ROUNAME) D + . S CURRCOV=$P(XVAL,"/"),CURRLIN=$P(XVAL,"/",2) + . S TOTCOV=TOTCOV+CURRCOV,TOTLIN=TOTLIN+CURRLIN + . I CURRLIN>0 S VAL=" ("_$J((100*CURRCOV)/CURRLIN,"",2),VAL=$E(VAL,$L(VAL)-6,$L(VAL)) + . S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="Routine "_ROUNAME_" "_$S(CURRLIN>0:VAL_"%)",1:" ------ ")_" "_CURRCOV_" out of "_CURRLIN_" lines covered" + S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="",LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="" + S LINNUM=LINNUM+1,@TEXTGLOB@(LINNUM)="Overall Analysis "_TOTCOV_" out of "_TOTLIN_" lines covered"_$S(TOTLIN>0:" ("_$P((100*TOTCOV)/TOTLIN,".")_"% coverage)",1:"") + Q + ; +TRIMDATA(ROULIST,GLOB) ; + N ROUNAME + S ROUNAME="" F S ROUNAME=$O(ROULIST(ROUNAME)) Q:ROUNAME="" K @GLOB@(ROUNAME) + Q + ; diff --git a/_utt1.m b/_utt1.m new file mode 100644 index 0000000..3780dee --- /dev/null +++ b/_utt1.m @@ -0,0 +1,189 @@ +%utt1 ; VEN/SMH-JLI - Testing routines for M-Unit;04/08/16 20:38 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Sam H. Habiel 07/2013-04/2014 + ; Additions and modifications made by Joel L. Ivey 05/2014-12/2015 + ; Modifications made by Sam H. Habiel 02/2016 + ; + ; THIS ROUTINE IS THE UNIFIED UNIT TESTER FOR ALL OF M-UNIT. + ; + ; Dear Users, + ; + ; I know about about the irony of a test suite for the testing suite, + ; so stop snikering. Aside from that, it's actually going to be hard. + ; + ; Truly yours, + ; + ; Sam H + ; + D EN^%ut($T(+0),1) ; Run tests here, be verbose. + N % S $P(%,"-",80)="-" + W !!,%,!,%,!,%,!,%,!! + K % + D EN^%ut($T(+0),2) ; Run tests here, be verbose with timings for each piece of code. + QUIT + ; +STARTUP ; M-Unit Start-Up - This runs before anything else. + ; ZEXCEPT: KBANCOUNT - created here, removed in SHUTDOWN + S ^TMP($J,"%ut","STARTUP")="" + S KBANCOUNT=1 + QUIT + ; +SHUTDOWN ; M-Unit Shutdown - This runs after everything else is done. + ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed here + K ^TMP($J,"%ut","STARTUP") + K KBANCOUNT + QUIT + ; + ; + ; +SETUP ; This runs before every test. + ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN + S KBANCOUNT=KBANCOUNT+1 + QUIT + ; +TEARDOWN ; This runs after every test + ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN + S KBANCOUNT=KBANCOUNT-1 + QUIT + ; + ; + ; +T1 ; @TEST - Make sure Start-up Ran + D CHKTF($D(^TMP($J,"%ut","STARTUP")),"Start-up node on ^TMP must exist") + QUIT + ; +T2 ; @TEST - Make sure Set-up runs + ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN + D CHKEQ(KBANCOUNT,2,"KBANCount not incremented properly at SETUP") + QUIT + ; +T3 ; @TEST - Make sure Teardown runs + ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN + D CHKEQ(KBANCOUNT,2,"KBANCount not decremented properly at TEARDOWN") + QUIT + ; +T4 ; Specified in XTMTAG + ; 140731 JLI - note that this will fail when run from the GUI runner, since it calls each tag separately + ; ZEXCEPT: %utETRY - newed and created in EN1^%ut + ; ZEXCEPT: %utGUI -- CONDITIONALLY DEFINED BY GUINEXT^%ut + I $G(%utGUI) D CHKEQ(%utETRY,"T4","T4 should be the value for %utETRY in the GUI Runner") + I '$G(%utGUI) D CHKEQ(%utETRY(4),"T4","T4 should be the collected as the fourth entry in %utETRY") + QUIT + ; +T5 ; ditto + ; ZEXCEPT: %ut - NEWed and created in EN1^%ut + D CHKTF(0,"This is an intentional failure.") + D CHKEQ(%ut("FAIL"),1,"By this point, we should have failed one test") + D FAIL^%ut("Intentionally throwing a failure") + D CHKEQ(%ut("FAIL"),2,"By this point, we should have failed two tests") + ; S %ut("FAIL")=0 ; Okay... Boy's and Girls... as the developer I can do that. + QUIT + ; +T6 ; ditto + ; ZEXCEPT: %ut - NEWed and created in EN1^%ut + N TESTCOUNT S TESTCOUNT=%ut("CHK") + D SUCCEED^%ut + D SUCCEED^%ut + D CHKEQ(%ut("CHK"),TESTCOUNT+2,"Succeed should increment the number of tests") + QUIT + ; +T7 ; Make sure we write to principal even though we are on another device + ; This is a rather difficult test to carry out for GT.M and Cache... + ; ZEXCEPT: GetEnviron,Util,delete,newversion,readonly - not really variables + N D + I +$SY=47 S D="/tmp/test.txt" ; All GT.M ; VMS not supported. + I +$SY=0 D ; All Cache + . I $ZVERSION(1)=2 S D=$SYSTEM.Util.GetEnviron("temp")_"\test.txt" I 1 ; Windows + . E S D="/tmp/test.txt" ; not windows; VMS not supported. + I +$SY=0 O D:"NWS" ; Cache new file + I +$SY=47 O D:(newversion) ; GT.M new file + U D + WRITE "HELLO",! + WRITE "HELLO",! + C D + ; + ; Now open back the file, and read the hello, but open in read only so + ; M-Unit will error out if it will write something out there. + ; + I +$SY=0 O D:"R" + I +$SY=47 O D:(readonly) + U D + N X READ X:1 + D CHKTF(X="HELLO") ; This should write to the screen the dot not to the file. + D CHKTF(($$LO($IO)=$$LO(D)),"IO device didn't get reset back") ; $$LO is b/c of a bug in Cache/Windows. $IO is not the same cas D. + I +$SY=0 C D:"D" + I +$SY=47 C D:(delete) + U $P + S IO=$IO + QUIT + ; + ; At the moment T8^%utt1 throws a fail, with no message + ; in the GUI runner. For some reason, both X and Y + ; variables are returned as null strings, while in the + ; command line runner, Y has a value containing the + ; word being sought + ; +T8 ; If IO starts with another device, write to that device as if it's the pricipal device + ; ZEXCEPT: GetEnviron,Util,delete,newversion,readonly - not really variables + N D + I +$SY=47 S D="/tmp/test.txt" ; All GT.M ; VMS not supported. + I +$SY=0 D ; All Cache + . I $ZVERSION(1)=2 S D=$SYSTEM.Util.GetEnviron("temp")_"\test.txt" I 1 ; Windows + . E S D="/tmp/test.txt" ; not windows; VMS not supported. + I +$SY=0 O D:"NWS" ; Cache new file + I +$SY=47 O D:(newversion) ; GT.M new file + S IO=D + U D + D ^%utt4 ; Run some Unit Tests + C D + I +$SY=0 O D:"R" ; Cache read only + I +$SY=47 O D:(readonly) ; GT.M read only + U D + N X,Y,Z R X:1,Y:1,Z:1 + I +$SY=0 C D:"D" + I +$SY=47 C D:(delete) + ;D CHKTF(Y["MAIN") ; JLI 140829 commented out, gui doesn't run verbose + D CHKTF((Y["MAIN")!(Z["T2 - Test 2"),"Write to system during test didn't work") + S IO=$P + QUIT + ; +COVRPTGL ; + N GL1,GL2,GL3,GL4 + S GL1=$NA(^TMP("%utCOVCOHORTSAVx",$J)) K @GL1 + S GL2=$NA(^TMP("%utCOVCOHORTx",$J)) K @GL2 + S GL3=$NA(^TMP("%utCOVRESULTx",$J)) K @GL3 + S GL4=$NA(^TMP("%utCOVREPORTx",$J)) K @GL4 + D SETGLOBS^%uttcovr(GL1,GL2) + D COVRPTGL^%ut1(GL1,GL2,GL3,GL4) + D CHKEQ($G(@GL4@("%ut1","ACTLINES")),"0/9","Wrong number of lines covered f>>or ACTLINES") + D CHKEQ($G(@GL4@("%ut1","ACTLINES",9))," QUIT CNT","Wrong result for last l>>ine not covered for ACTLINES") + D CHKEQ($G(@GL4@("%ut1","CHEKTEST")),"8/10","Wrong number of lines covered >>for CHEKTEST") + D CHKEQ($G(@GL4@("%ut1","CHEKTEST",39))," . Q","Wrong result for last line >>not covered for CHEKTEST") + K @GL1,@GL2,@GL3,@GL4 + Q + ; +LO(X) Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz") + ; Shortcut methods for M-Unit +CHKTF(X,Y) ; + D CHKTF^%ut(X,$G(Y)) + QUIT + ; +CHKEQ(A,B,M) ; + D CHKEQ^%ut(A,B,$G(M)) + QUIT + ; +XTENT ; Entry points + ;;T4;Entry point using XTMENT + ;;T5;Error count check + ;;T6;Succeed Entry Point + ;;T7;Make sure we write to principal even though we are on another device + ;;T8;If IO starts with another device, write to that device as if it's the pricipal device + ;;COVRPTGL;coverage report returning global + ; +XTROU ; Routines containing additional tests + ;;%utt2; old %utNITU + ;;%utt4; old %utNITW + ;;%utt5; + ;;%utt6; + ;;%uttcovr;coverage related tests diff --git a/_utt2.m b/_utt2.m new file mode 100644 index 0000000..d1ffdcb --- /dev/null +++ b/_utt2.m @@ -0,0 +1,15 @@ +%utt2 ; VEN/SMH - Bad Ass Continuation of Unit Tests;04/08/16 20:38 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Sam H. Habiel + ; Modifications made by Joel L. Ivey 05/2014-09/2015 + ; + ; +T11 ; @TEST An @TEST Entry point in Another Routine invoked through XTROU offsets + D CHKTF^%ut(1) + QUIT +T12 ; + D CHKTF^%ut(1) + QUIT +XTENT ; + ;;T12;An XTENT offset entry point in Another Routine invoked through XTROU offsets diff --git a/_utt3.m b/_utt3.m new file mode 100644 index 0000000..cc11999 --- /dev/null +++ b/_utt3.m @@ -0,0 +1,47 @@ +%utt3 ; VEN/SMH-JLI - Unit Tests Coverage Tests;04/08/16 20:38 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Sam H. Habiel 07/2013-04/2014 + ; Additions and modifications made by Joel L. Ivey 05/2014-08/2015 + ; +XTMUNITV ; VEN/SMH - Unit Tests Coverage Tests;2014-04-16 7:14 PM + ; + ; *** BE VERY CAREFUL IN MODIFIYING THIS ROUTINE *** + ; *** THE UNIT TEST COUNTS ACTIVE AND INACTIVE LINES OF CODE *** + ; *** IF YOU MODIFY THIS, MODIFY XTMUNITW AS WELL *** + ; + ; Coverage tester in %utt4 + ; 20 Lines of code + ; 5 do not run as they are dead code + ; Expected Coverage: 15/20 = 75% + ; +STARTUP ; Doesn't count + N X ; Counts + S X=1 ; Counts + QUIT ; Counts + ; +SHUTDOWN K X,Y QUIT ; Counts; ZEXCEPT: X,Y + ; +SETUP S Y=$G(Y)+1 QUIT ; Counts + ; +TEARDOWN ; Doesn't count + S Y=Y-1 ; Counts + QUIT ; Counts + ; +T1 ; @TEST Test 1 + D CHKTF^%ut($D(Y)) ; Counts + QUIT ; Counts + ; +T2 ; @TEST Test 2 + D INTERNAL(1) ; Counts + D CHKTF^%ut(1) ; Counts + QUIT ; Counts + S X=1 ; Dead code + QUIT ; Dead code + ; +INTERNAL(A) ; Counts + S A=A+1 ; Counts + QUIT ; Counts + S A=2 ; Dead code + S Y=2 ; Dead code + QUIT ; Dead code diff --git a/_utt4.m b/_utt4.m new file mode 100644 index 0000000..7564f7e --- /dev/null +++ b/_utt4.m @@ -0,0 +1,22 @@ +%utt4 ; VEN/SMH/JLI - Coverage Test Runner;04/08/16 20:38 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Sam H. Habiel 07/2013-04/2014 + ; Additions and modifications made by Joel L. Ivey 05/2014-08/2015 + ; +XTMUNITW ; VEN/SMH - Coverage Test Runner;2014-04-17 3:30 PM + ;;7.3;KERNEL TOOLKIT;; + ; + ; This tests code in XTMUNITV for coverage + D EN^%ut($T(+0),1) QUIT + ; +MAIN ; @TEST - Test coverage calculations + Q:$D(^TMP("%uttcovr",$J)) ; already running coverage analysis from %uttcovr + S ^TMP("%utt4val",$J)=1 + D COV^%ut("%utt3","D EN^%ut(""%utt3"",1)",-1) ; Only produce output global. + D CHKEQ^%ut("14/19",^TMP("%utCOVREPORT",$J)) + D CHKEQ^%ut("2/5",^TMP("%utCOVREPORT",$J,"%utt3","INTERNAL")) + D CHKTF^%ut($D(^TMP("%utCOVREPORT",$J,"%utt3","T2",4))) + D CHKEQ^%ut("1/1",^TMP("%utCOVREPORT",$J,"%utt3","SETUP")) + K ^TMP("%utt4val",$J) + QUIT diff --git a/_utt5.m b/_utt5.m new file mode 100644 index 0000000..6bf9f86 --- /dev/null +++ b/_utt5.m @@ -0,0 +1,138 @@ +%utt5 ;JLI - test for aspects of MUnit functionality ;04/08/16 20:38 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Joel L. Ivey 05/2014-12/2015. + ; + Q + ; +OLDSTYLE ; + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %ut("ENT")="OLDSTYLE",%utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"OLDSTYLE")="" + D CHKEQ^%ut(5,5,"SET EQUAL ON PURPOSE - OLDSTYLE DONE") + D CHKTF^%ut(4=4,"MY EQUAL VALUE") + Q + ; +OLDSTYL1 ; + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %ut("ENT")="OLDSTYL1",%utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"OLDSTYL1")="" + D CHKEQ^%ut(4,4,"SET EQUAL ON PURPOSE - OLDSTYL1 DONE") + Q + ; +NEWSTYLE ; @TEST identify new style test indicator functionality + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %ut("ENT")="NEWSTYLE" S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"NEWSTYLE")="" + D CHKEQ^%ut(4,4,"SET EQUAL ON PURPOSE - NEWSTYLE DONE") + Q + ; +BADCHKEQ ; + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %ut("ENT")="BADCHKEQ" S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"BADCHKEQ")="" + D CHKEQ^%ut(4,3,"SET UNEQUAL ON PURPOSE - SHOULD FAIL") + Q + ; +BADCHKTF ; + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %ut("ENT")="BADCHKTF" S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"BADCHKTF")="" + D CHKTF^%ut(0,"SET FALSE (0) ON PURPOSE - SHOULD FAIL") + Q + ; +BADERROR ; + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + N X + I $D(%utt6var) S %ut("ENT")="BADERROR" S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"BADERROR")="" + ; following syntax error is on purpose to throw an error + S X= ; syntax error on purpose + Q + ; +CALLFAIL ; + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + N X + I $D(%utt6var) S %ut("ENT")="CALLFAIL" S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"CALLFAIL")="" + D FAIL^%ut("Called FAIL to test it") + Q + ; +LEAKSOK ; + N CODE,LOCATN,MYVALS,X + S CODE="S X=$$NOW^XLFDT()",LOCATN="LEAKSOK TEST",MYVALS("X")="" + D CHKLEAKS^%ut(CODE,LOCATN,.MYVALS) ; should find no leaks + Q + ; +LEAKSBAD ; + N CODE,LOCATN,MYVALS,X + S CODE="S X=$$NOW^XLFDT()",LOCATN="LEAKSBAD TEST - X NOT SPECIFIED" + D CHKLEAKS^%ut(CODE,LOCATN,.MYVALS) ; should find X since it isn't indicated + Q + ; +NVLDARG1 ; + D CHKEQ^%ut(1) + Q + ; +ISUTEST ; + D CHKTF^%ut($$ISUTEST^%ut,"ISUTEST returned FALSE!") + Q + ; +BADFORM1(X) ; @TEST should not be selected - arguments + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %ut("ENT")="NEWSTYLE" S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"BADFORM1")="" + D CHKEQ^%ut(4,3,"SHOULD NOT BE SELECTED - ARGUMENTS - BADFORM1") + Q + ; +BADFORM2 ; ABC @TEST should not be selected - @TEST NOT FIRST + ; ZEXCEPT: %ut - Newed in EN^%zu + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"BADFORM2")="" + D CHKEQ^%ut(4,3,"SHOULD NOT BE SELECTED - @TEST NOT FIRST - BADFORM2") + Q + ; +STARTUP ; + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + ; ZEXCEPT: KBANCOUNT created here, killed in SHUTDOWN + I $D(%utt6var),$D(^TMP("%utt5",$J)) K ^TMP("%utt5",$J) + I $D(%utt6var) S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"STARTUP")="" + ; following brought from %utt1, since only one STARTUP can RUN in a set + I '$D(%utt6var) D + . S ^TMP($J,"%ut","STARTUP")="" + . S KBANCOUNT=1 + . Q + Q + ; +SHUTDOWN ; + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + ; ZEXCEPT: KBANCOUNT created in STARTUP, killed here + I $D(%utt6var) S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"SHUTDOWN")="" + ; following brought from %utt1, since only one SHUTDOWN can RUN in a set + I '$D(%utt6var) D + . K ^TMP($J,"%ut","STARTUP") + . K KBANCOUNT + . Q + Q + ; +SETUP ; + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"SETUP")="" + Q + ; +TEARDOWN ; + ; ZEXCEPT: %utt6cnt,%utt6var - if present, NEWED following top entry of routine %utt6 + I $D(%utt6var) S %utt6cnt=$G(%utt6cnt)+1,^TMP("%utt5",$J,%utt6cnt,"TEARDOWN")="" + Q + ; +XTENT ; + ;;OLDSTYLE; identify old style test indicator functionality + ;;OLDSTYL1; identify old style test indicator 2 + ;;BADCHKEQ; CHKEQ should fail on unequal value + ;;BADCHKTF; CHKTF should fail on false value + ;;BADERROR; throws an error on purpose + ;;CALLFAIL; called FAIL to test it + ;;LEAKSOK;check leaks should be ok + ;;LEAKSBAD;check leaks with leak + ;;NVLDARG1;check invalid arg in CHKEQ + ;;ISUTEST;check ISUTEST inside unit test diff --git a/_utt6.m b/_utt6.m new file mode 100644 index 0000000..ad5c133 --- /dev/null +++ b/_utt6.m @@ -0,0 +1,125 @@ +%utt6 ;JLI - Unit tests for MUnit functionality ;04/08/16 20:49 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Joel L. Ivey 05/2014-12/2015 + ; + ; + ; The counts for the command line processing are based on the number of unit test tags + ; determined for the GUI processing as well. The numbers are 2 (startup and shutdown) + ; + 3 x the number of tests present. + ; + ; run unit tests by command line + N VERBOSE + S VERBOSE=0 +VERBOSE ; + I '$D(VERBOSE) N VERBOSE S VERBOSE=1 + N ZZUTCNT,UTTCNT,UTTEXPCT,UTTI,UTTX,ZZUTRSLT,%utt5,%utt6,%utt6var + W !!,"RUNNING COMMAND LINE TESTS VIA DOSET^%ut",! + D DOSET^%ut(1,VERBOSE) ; run `1 in M-UNIT TEST GROUP file + ; + W !!!,"Running command line tests by RUNSET^%ut",! + D RUNSET^%ut("TESTS FOR UNIT TEST ROUTINES") + ; + ; Call GUISET to obtain list of tags via entry in M-UNIT TEST GROUP file + ; silent to the user + D GUISET^%ut(.%utt6,1) + K ^TMP("%utt6_GUISET",$J) M ^TMP("%utt6_GUISET",$J)=@%utt6 + ; + W !!!,"RUNNING COMMAND LINE UNIT TESTS FOR %utt5",! + N ZZUTCNT,UTTCNT,UTTEXPCT,UTTI,UTTX,ZZUTRSLT + S ZZUTCNT=0 + K ^TMP("%utt5",$J) ; kill any contents of data storage + D EN^%ut("%utt5",VERBOSE) ; should do STARTUP(1x), then SETUP, test, TEARDOWN (each together 3x) and SHUTDOWN (1x) + K ^TMP("%utt5_C",$J) M ^TMP("%utt5_C",$J)=^TMP("%utt5",$J) + ; + ; now run unit tests by GUI - first determines unit test tags + W !!!,"RUNNING UNIT TESTS FOR %utt5 VIA GUI CALLS - Silent",! + S ZZUTCNT=0 + K ^TMP("%utt5",$J),^TMP("%utt6",$J) + D GUILOAD^%ut(.%utt6,"%utt5") + M ^TMP("%utt6",$J)=@%utt6 + S %utt6=$NA(^TMP("%utt6",$J)) + ; then run each tag separately + ; UTTCNT is count of unit test tags, which can be determined for GUI call for each unit test tag + S UTTCNT=0 F UTTI=1:1 S UTTX=$G(@%utt6@(UTTI)) Q:UTTX="" I $P(UTTX,U,2)'="" S UTTCNT=UTTCNT+1 D GUINEXT^%ut(.ZZUTRSLT,$P(UTTX,U,2)_U_$P(UTTX,U)) + ; and close it with a null routine name + D GUINEXT^%ut(.ZZUTRSLT,"") + K ^TMP("%utt5_G",$J) M ^TMP("%utt5_G",$J)=^TMP("%utt5",$J) + S UTTEXPCT=2+(3*UTTCNT) ; number of lines that should be in the global nodes for command line and GUI + ; + W !!,"NOW RUNNING UNIT TESTS FOR %uttcovr",!! + D EN^%ut("%uttcovr",VERBOSE) + ; + ; now run the unit tests in this routine + W !!,"NOW RUNNING UNIT TESTS FOR %utt6",!! + D EN^%ut("%utt6",VERBOSE) + K ^TMP("%utt5",$J),^TMP("%utt5_C",$J),^TMP("%utt5_G",$J),^TMP("%utt6",$J),^TMP("%utt6_GUISET",$J) + ; clean up after GUI calls as well + K ^TMP("GUI-MUNIT",$J),^TMP("GUINEXT",$J),^TMP("MUNIT-%utRSLT",$J) + Q + ; + ; + ; WARNING -- WARNING -- WARNING + ; If the number of NEW STYLE tests in %utt5 is increased (it is currently 1), then the following + ; test will need to be updated to reflect the change(s) + ; END OF WARNING -- END OF WARNING -- END OF WARNING + ; +SETROUS ; @TEST - generate array with indices of routines to exclude + N ROU,XCLDROUS,ROULIST + S XCLDROUS(1)="ROU1NAME,ROU2NAME" + S XCLDROUS("ROUNAME3")="ROUNAME4,ROUNAME5" + D SETROUS^%utcover(.ROULIST,.XCLDROUS,1) + D CHKTF('$D(ROULIST(1)),"SETROUS returned number for routine") + D CHKTF($D(ROULIST("ROU1NAME")),"Didn't get first name on numeric subscript") + D CHKTF($D(ROULIST("ROU2NAME")),"Didn't get second name on numeric subscript") + D SETROUS^%utcover(.ROULIST,.XCLDROUS,"ROUNAME3") + D CHKTF($D(ROULIST("ROUNAME3")),"Didn't get name for routine argument") + D CHKTF($D(ROULIST("ROUNAME4")),"Didn't get first name on routine subscript") + D CHKTF($D(ROULIST("ROUNAME5")),"Didn't get second name on routine subscript") + Q + ; +NEWSTYLE ; tests return of valid new style or @TEST indicators + N LIST + D NEWSTYLE^%ut1(.LIST,"%utt5") + D CHKEQ^%ut(LIST,1,"Returned an incorrect number ("_LIST_") of New Style indicators - should be one") + I LIST>0 D CHKEQ^%ut(LIST(1),"NEWSTYLE^identify new style test indicator functionality","Returned incorrect TAG^reason "_LIST(1)) + I LIST>0 D CHKEQ^%ut($G(LIST(2)),"","Returned a value for LIST(2) - should not have any value (i.e., null)") + ; the following is basically just for coverage + D PICKSET^%ut + Q + ; +CKGUISET ; + ; ZEXCEPT: %utt6var - if present, is NEWed and created in code following VERBOSE + I '$D(%utt6var) Q + N MAX + S MAX=$O(^TMP("%utt6_GUISET",$J,""),-1) + D CHKTF(^TMP("%utt6_GUISET",$J,MAX)["%utt6^NEWSTYLE","GUISET returned incorrect list") + Q + ; +CHKCMDLN ; check command line processing of %utt5 + ; ZEXCEPT: UTTEXPCT,%utt6var - if present NEWed and created in code following VERBOSE tag + I '$D(%utt6var) Q + D CHKTF($D(^TMP("%utt5_C",$J,UTTEXPCT))=10,"Not enough entries in %utt5 expected "_UTTEXPCT) + D CHKTF($D(^TMP("%utt5_C",$J,UTTEXPCT+1))=0,"Too many entries in %utt5 expected "_UTTEXPCT) + D CHKTF($O(^TMP("%utt5_C",$J,1,""))="STARTUP","Incorrect function for entry 1,'"_$O(^TMP("%utt5_C",$J,1,""))_"' should be 'STARTUP'") + D CHKTF($O(^TMP("%utt5_C",$J,UTTEXPCT,""))="SHUTDOWN","Incorrect function for entry "_UTTEXPCT_", '"_$O(^TMP("%utt5_C",$J,UTTEXPCT,""))_"' should be 'SHUTDOWN'") + Q + ; +CHKGUI ; check GUI processing of %utt5 + ; ZEXCEPT: UTTEXPCT,%utt6var - if present NEWed and created in code following VERBOSE tag + I '$D(%utt6var) Q + D CHKTF($D(^TMP("%utt5_G",$J,UTTEXPCT))=10,"Not enough entries in %utt5 expected "_UTTEXPCT) + D CHKTF($D(^TMP("%utt5_G",$J,UTTEXPCT+1))=0,"Too many entries in %utt5 expected "_UTTEXPCT) + D CHKTF($O(^TMP("%utt5_G",$J,1,""))="STARTUP","Incorrect function for entry 1,'"_$O(^TMP("%utt5Z_G",1,""))_"' should be 'STARTUP'") + D CHKTF($O(^TMP("%utt5_G",$J,UTTEXPCT,""))="SHUTDOWN","Incorrect function for entry "_UTTEXPCT_", '"_$O(^TMP("%utt5_G",$J,UTTEXPCT,""))_"' should be 'SHUTDOWN'") + Q + ; +CHKTF(VALUE,MESSAGE) ; + D CHKTF^%ut($G(VALUE),$G(MESSAGE)) + Q + ; +XTENT ; + ;;CHKCMDLN;check command line processing of %utt5 + ;;CHKGUI;check GUI processing of %utt5 + ;;CKGUISET;check list of tests returned by GUISET + ;;NEWSTYLE;test return of valid new style or @TEST indicators diff --git a/_uttcovr.m b/_uttcovr.m new file mode 100644 index 0000000..a9ce4c7 --- /dev/null +++ b/_uttcovr.m @@ -0,0 +1,323 @@ +%uttcovr ;JIVEYSOFT/JLI - runs coverage tests on %ut and %ut1 routines via unit tests ;04/08/16 20:49 + ;;1.4;MASH UTILITIES;;APR 11, 2016;Build 2 + ; Submitted to OSEHRA Apr 11, 2016 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html) + ; Original routine authored by Joel L. Ivey 05/2014-12/2015 + ; Modified by Joel L. Ivey 02/2016-03/2016 + ; + ; + ; ZEXCEPT: DTIME - if present the value is Kernel timeout for reads + N RUNCODE,XCLUDE + ; + ; Have it run the following entry points or, if no ^, call EN^%ut with routine name + S RUNCODE(1)="^%utt1,%utt1,^%utt6,VERBOSE^%utt6,%uttcovr,^%ut,^%ut1,^%utcover" + S RUNCODE("ENTRY^%uttcovr")="" + ; Have the analysis EXCLUDE the following routines from coverage - unit test routines + S XCLUDE(1)="%utt1,%utt2,%utt3,%utt4,%utt5,%utt6,%uttcovr" + S XCLUDE(2)="%utf2hex" ; a GT.M system file, although it wasn't showing up anyway + M ^TMP("%uttcovr",$J,"XCLUDE")=XCLUDE + D COVERAGE^%ut("%ut*",.RUNCODE,.XCLUDE,3) + Q + ; +ENTRY ; + K ^TMP("ENTRY^%uttcovr",$J,"VALS") + M ^TMP("ENTRY^%uttcovr",$J,"VALS")=^TMP("%ut",$J,"UTVALS") + K ^TMP("%ut",$J,"UTVALS") + ; these tests run outside of unit tests to handle CHKLEAKS calls not in unit tests + ; they need data set, so they are called in here + ; LEAKSOK ; + N CODE,LOCATN,MYVALS,X,I + S CODE="S X=$$NOW^XLFDT()",LOCATN="LEAKSOK TEST",MYVALS("X")="" + D CHKLEAKS^%ut(CODE,LOCATN,.MYVALS) ; should find no leaks + ; LEAKSBAD ; + N CODE,LOCATN,MYVALS,X + S CODE="S X=$$NOW^XLFDT()",LOCATN="LEAKSBAD TEST - X NOT SPECIFIED" + D CHKLEAKS^%ut(CODE,LOCATN,.MYVALS) ; should find X since it isn't indicated + ; try to run coverage + W !,"xxxxxxxxxxxxxxxxxxxx GOING TO COV^%ut FOR %utt5 at 3",!!! + D COV^%ut("%ut1","D EN^%ut(""%utt5"")",3) + W !,"xxxxxxxxxxxxxxxxxxxx GOING TO COV^%ut FOR %utt5 at -1",!!! + D COV^%ut("%ut1","D EN^%ut(""%utt5"")",-1) + N RUNCODE S RUNCODE(1)="^%utt4,^%ut" + N XCLUDE M XCLUDE=^TMP("%uttcovr",$J,"XCLUDE") + W !,"xxxxxxxxxxxxxxxxxxxx GOING TO MULTAPIS for %utt4 and %ut",!!! + D MULTAPIS^%ut(.RUNCODE) + W !,"xxxxxxxxxxxxxxxxxxxx GOING TO COVERAGE for %utt4 and %ut at 3",!!! + D COVERAGE^%ut("%ut*",.RUNCODE,.XCLUDE,3) + N GLT S GLT=$NA(^TMP("%uttcovr-text",$J)) K @GLT + W !,"xxxxxxxxxxxxxxxxxxxx LISTING DATA VIA LIST",!!! + D LIST^%utcover(.XCLUDE,3,GLT) ; get coverage for listing and trimdata in %utcover + F I=1:1 Q:'$D(@GLT@(I)) W !,@GLT@(I) + K @GLT + ; restore unit test totals from before entry + K ^TMP("%ut",$J,"UTVALS") + M ^TMP("%ut",$J,"UTVALS")=^TMP("ENTRY^%uttcovr",$J,"VALS") + K ^TMP("ENTRY^%uttcovr",$J,"VALS") + W !,"xxxxxxxxxxxxxxxxxxxx Finished in ENTRY^%uttcovr",!!! + Q + ; +RTNANAL ; @TEST - routine analysis + N ROUS,GLB + S ROUS("%utt4")="" + S GLB=$NA(^TMP("%uttcovr-rtnanal",$J)) K @GLB + D RTNANAL^%ut1(.ROUS,GLB) + D CHKTF($D(@GLB@("%utt4","MAIN"))>1,"Not enough 'MAIN' nodes found") + D CHKTF($G(@GLB@("%utt4","MAIN",3))["D COV^%ut(""%utt3"",""D EN^%ut(""""%utt3"""",1)"",-1)","Incorrect data for line 2 in MAIN") + D CHKTF($G(@GLB@("%utt4","MAIN",9))=" QUIT","Final QUIT not on expected line") + K @GLB + Q + ; +COVCOV ; @TEST - check COVCOV - remove seen lines + N C,R + S C=$NA(^TMP("%uttcovr_C",$J)) + S R=$NA(^TMP("%uttcovr_R",$J)) + S @C@("ROU1")="" + S @C@("ROU2")="",@R@("ROU2")="" + S @C@("ROU2","TAG1")="",@R@("ROU2","TAG1")="" + S @C@("ROU2","TAG1",1)="AAA" + S @C@("ROU2","TAG1",2)="AAA",@R@("ROU2","TAG1",2)="AAA" + S @C@("ROU2","TAG1",3)="ABB",@R@("ROU2","TAG1",3)="ABB" + S @C@("ROU2","TAG2",6)="ACC" + S @C@("ROU2","TAG2",7)="ADD",@R@("ROU2","TAG2",7)="ADD" + S @C@("ROU3","TAG1",2)="BAA",@R@("ROU3","TAG1",2)="BAA" + S @C@("ROU3","TAG1",3)="CAA" + S @C@("ROU3","TAG1",4)="DAA" + S @C@("ROU3","TAG1",5)="EAA",@R@("ROU3","TAG1",5)="EAA" + S @C@("ROU3","TAG1",6)="FAA",@R@("ROU3","TAG1",6)="FAA" + D COVCOV^%ut1(C,R) + D CHKTF($D(@C@("ROU2","TAG1",1)),"Invalid value for ""ROU2"",""TAG1"",1") + D CHKTF('$D(@C@("ROU2","TAG1",2)),"Unexpected value for ""ROU2"",""TAG1"",1") + D CHKTF($D(@C@("ROU2","TAG2",6)),"Invalid value for ""ROU2"",""TAG1"",1") + D CHKTF('$D(@C@("ROU2","TAG2",7)),"Unexpected value for ""ROU2"",""TAG1"",1") + D CHKTF($D(@C@("ROU3","TAG1",4)),"Invalid value for ""ROU2"",""TAG1"",1") + D CHKTF('$D(@C@("ROU3","TAG1",5)),"Unexpected value for ""ROU2"",""TAG1"",1") + K @C,@R + Q + ; +COVRPT ; @TEST + N GL1,GL2,GL3,GL4,VRBOSITY,GL5 + S GL1=$NA(^TMP("%utCOVCOHORTSAVx",$J)) K @GL1 + S GL2=$NA(^TMP("%utCOVCOHORTx",$J)) K @GL2 + S GL3=$NA(^TMP("%utCOVRESULTx",$J)) K @GL3 + S GL4=$NA(^TMP("%utCOVREPORTx",$J)) K @GL4 + S GL5=$NA(^TMP("%ut1-covrpt",$J)) K @GL5 + D SETGLOBS(GL1,GL2) + S VRBOSITY=1 + D COVRPT^%ut1(GL1,GL2,GL3,VRBOSITY) + D CHKEQ("COVERAGE PERCENTAGE: 42.11",$G(@GL5@(5)),"Verbosity 1 - not expected percentage value") + D CHKEQ(" %ut1 42.11% 8 out of 19",$G(@GL5@(9)),"Verbosity 1 - not expected value for line 9") + D CHKTF('$D(@GL5@(10)),"Verbosity 1 - unexpected data in 10th line") + ; + S VRBOSITY=2 + D COVRPT^%ut1(GL1,GL2,GL3,VRBOSITY) + D CHKEQ(" ACTLINES 0.00% 0 out of 9",$G(@GL5@(10)),"Verbosity 2 - not expected value for 10th line") + D CHKEQ(" CHEKTEST 80.00% 8 out of 10",$G(@GL5@(11)),"Verbosity 2 - not expected value for 11th line") + D CHKTF('$D(@GL5@(12)),"Verbosity 2 - unexpected data for 12th line") + ; + S VRBOSITY=3 + D COVRPT^%ut1(GL1,GL2,GL3,VRBOSITY) + D CHKEQ(" ACTLINES 0.00% 0 out of 9",$G(@GL5@(10)),"Verbosity 3 - unexpected value for line 10") + D CHKEQ("ACTLINES+9: QUIT CNT",$G(@GL5@(19)),"Verbosity 3 - unexpected value for line 19") + D CHKEQ(" CHEKTEST 80.00% 8 out of 10",$G(@GL5@(20)),"Verbosity 3 - unexpected value for line 20") + D CHKEQ("CHEKTEST+39: . Q",$G(@GL5@(22)),"Verbosity 3 - unexpected value for line 22") + D CHKTF('$D(@GL5@(23)),"Verbosity 3 - unexpected line 23") + K @GL1,@GL2,@GL3,@GL4,@GL5 + Q + ; +COVRPTLS ; @TEST - coverage report returning text in global + N GL1,GL2,GL3,GL4,VRBOSITY + S GL1=$NA(^TMP("%utCOVCOHORTSAVx",$J)) K @GL1 + S GL2=$NA(^TMP("%utCOVCOHORTx",$J)) K @GL2 + S GL3=$NA(^TMP("%utCOVRESULTx",$J)) K @GL3 + S GL4=$NA(^TMP("%utCOVREPORTx",$J)) K @GL4 + D SETGLOBS(GL1,GL2) + S VRBOSITY=1 + D COVRPTLS^%ut1(GL1,GL2,GL3,VRBOSITY,GL4) + D CHKEQ("COVERAGE PERCENTAGE: 42.11",$G(@GL4@(5)),"Verbosity 1 - not expected percentage value") + D CHKEQ(" %ut1 42.11% 8 out of 19",$G(@GL4@(9)),"Verbosity 1 - not expected value for line 9") + D CHKTF('$D(@GL4@(10)),"Verbosity 1 - unexpected data in 10th line") + K @GL4 + ; + S VRBOSITY=2 + D COVRPTLS^%ut1(GL1,GL2,GL3,VRBOSITY,GL4) + D CHKEQ(" ACTLINES 0.00% 0 out of 9",$G(@GL4@(10)),"Verbosity 2 - not expected value for 10th line") + D CHKEQ(" CHEKTEST 80.00% 8 out of 10",$G(@GL4@(11)),"Verbosity 2 - not expected value for 11th line") + D CHKTF('$D(@GL4@(12)),"Verbosity 2 - unexpected data for 12th line") + K @GL4 + ; + S VRBOSITY=3 + D COVRPTLS^%ut1(GL1,GL2,GL3,VRBOSITY,GL4) + D CHKEQ(" ACTLINES 0.00% 0 out of 9",$G(@GL4@(10)),"Verbosity 3 - unexpected value for line 10") + D CHKEQ("ACTLINES+9: QUIT CNT",$G(@GL4@(19)),"Verbosity 3 - unexpected value for line 19") + D CHKEQ(" CHEKTEST 80.00% 8 out of 10",$G(@GL4@(20)),"Verbosity 3 - unexpected value for line 20") + D CHKEQ("CHEKTEST+39: . Q",$G(@GL4@(22)),"Verbosity 3 - unexpected value for line 22") + D CHKTF('$D(@GL4@(23)),"Verbosity 3 - unexpected line 23") + ; + K @GL1,@GL2,@GL3,@GL4 + Q + ; +TRIMDATA ; @TEST - TRIMDATA in %utcover + N GL1,XCLUD + S GL1=$NA(^TMP("%uttcovr-trimdata",$J)) K @GL1 + S @GL1@("GOOD",1)="1" + S @GL1@("BAD",1)="1" + S XCLUD("BAD")="" + D TRIMDATA^%utcover(.XCLUD,GL1) + D CHKTF($D(@GL1@("GOOD")),"GOOD ENTRY WAS REMOVED") + D CHKTF('$D(@GL1@("BAD")),"ENTRY WAS NOT TRIMMED") + K @GL1,XCLUD + Q + ; +LIST ; @TEST - LIST in %utcover + N GL1,GLT S GL1=$NA(^TMP("%uttcovr-list",$J)),GLT=$NA(^TMP("%uttcovr-text",$J)) + S @GL1@("%ut1")="89/160" + S @GL1@("%ut1","%ut1")="2/2" + S @GL1@("%ut1","ACTLINES")="0/8" + S @GL1@("%ut1","ACTLINES",2)=" N CNT S CNT=0" + S @GL1@("%ut1","ACTLINES",3)=" N REF S REF=GL" + S @GL1@("%ut1","ACTLINES",4)=" N GLQL S GLQL=$QL(GL)" + S @GL1@("%ut1","ACTLINES",5)=" F S REF=$Q(@REF) Q:REF="""" Q:(GL'=$NA(@REF,GLQL)) D" + S @GL1@("%ut1","ACTLINES",6)=" . N REFQL S REFQL=$QL(REF)" + S @GL1@("%ut1","ACTLINES",7)=" . N LASTSUB S LASTSUB=$QS(REF,REFQL)" + S @GL1@("%ut1","ACTLINES",8)=" . I LASTSUB?1.N S CNT=CNT+1" + S @GL1@("%ut1","ACTLINES",9)=" QUIT CNT" + S @GL1@("%ut1","CHECKTAG")="11/11" + S @GL1@("%ut1","CHEKTEST")="10/10" + N XCLUD S XCLUD("%utt1")="" + D LIST^%utcover(.XCLUD,1,GLT,GL1) + D CHKEQ("Routine %ut1 (55.63%) 89 out of 160 lines covered",$G(@GLT@(3)),"Verbosity 1 - Unexpected text for line 3") + D CHKEQ("Overall Analysis 89 out of 160 lines covered (55% coverage)",$G(@GLT@(6)),"Verbosity 1 - unexpected text for line 6") + D CHKTF('$D(@GLT@(7)),"Verbosity 1 - Unexpected line 7 present") + K @GLT + ; + D LIST^%utcover(.XCLUD,2,GLT,GL1) + D CHKEQ(" - Summary",$G(@GLT@(4)),"Verbosity 2 - unexpected text at line 4") + D CHKEQ(" Tag ACTLINES^%ut1 (0.00%) 0 out of 8 lines covered",$G(@GLT@(6)),"Verbosity 2 - unexpected text at line 6") + D CHKEQ(" Tag CHEKTEST^%ut1 (100.00%) 10 out of 10 lines covered",$G(@GLT@(8)),"Verbosity 2 - unexpected text at line 8") + D CHKTF($D(@GLT@(14)),"Verbosity 2 - expected line at line 14") + D CHKTF('$D(@GLT@(15)),"Verbosity 2 - unexpected line at line 15") + K @GLT + ; + D LIST^%utcover(.XCLUD,3,GLT,GL1) + D CHKEQ(" Tag %ut1^%ut1 (100.00%) 2 out of 2 lines covered",$G(@GLT@(5)),"Verbosity 3 - Incorrect text at line 5") + D CHKEQ(" ACTLINES+9 QUIT CNT",$G(@GLT@(15)),"Verbosity 3 - incorrect line 15") + D CHKTF($D(@GLT@(31)),"Verbosity 3 - expected data in line 31") + D CHKTF('$D(@GLT@(32)),"Verbosity 3 - did not expect a line 32") + ; + K @GL1,@GLT + Q + ; +SETGLOBS(GL1,GL2) ; + S @GL1@("%ut1","ACTLINES")="ACTLINES" + S @GL1@("%ut1","ACTLINES",0)="ACTLINES(GL) ; [Private] $$ ; Count active lines" + S @GL1@("%ut1","ACTLINES",2)=" N CNT S CNT=0" + S @GL1@("%ut1","ACTLINES",3)=" N REF S REF=GL" + S @GL1@("%ut1","ACTLINES",4)=" N GLQL S GLQL=$QL(GL)" + S @GL1@("%ut1","ACTLINES",5)=" F S REF=$Q(@REF) Q:REF="""" Q:(GL'=$NA(@REF,GLQL)) D" + S @GL1@("%ut1","ACTLINES",6)=" . N REFQL S REFQL=$QL(REF)" + S @GL1@("%ut1","ACTLINES",7)=" . N LASTSUB S LASTSUB=$QS(REF,REFQL)" + S @GL1@("%ut1","ACTLINES",8)=" . I LASTSUB?1.N S CNT=CNT+1" + S @GL1@("%ut1","ACTLINES",9)=" QUIT CNT" + S @GL1@("%ut1","CHEKTEST")="CHEKTEST" + S @GL1@("%ut1","CHEKTEST",0)="CHEKTEST(%utROU,%ut,%utUETRY) ; Collect Test list." + S @GL1@("%ut1","CHEKTEST",13)=" N I,LIST" + S @GL1@("%ut1","CHEKTEST",14)=" S I=$L($T(@(U_%utROU))) I I<0 Q ""-1^Invalid Routine Name""" + S @GL1@("%ut1","CHEKTEST",31)=" D NEWSTYLE(.LIST,%utROU)" + S @GL1@("%ut1","CHEKTEST",32)=" F I=1:1:LIST S %ut(""ENTN"")=%ut(""ENTN"")+1,%utUETRY(%ut(""ENTN""))=$P(LIST(I),U),%utUETRY(%ut(""ENTN""),""NAME"")=$P(LIST(I),U,2,99)" + S @GL1@("%ut1","CHEKTEST",37)=" N %utUI F %utUI=1:1 S %ut(""ELIN"")=$T(@(""XTENT+""_%utUI_""^""_%utROU)) Q:$P(%ut(""ELIN""),"";"",3)="""" D" + S @GL1@("%ut1","CHEKTEST",38)=" . S %ut(""ENTN"")=%ut(""ENTN"")+1,%utUETRY(%ut(""ENTN""))=$P(%ut(""ELIN""),"";"",3),%utUETRY(%ut(""ENTN""),""NAME"")=$P(%ut(""ELIN""),"";"",4)" + S @GL1@("%ut1","CHEKTEST",39)=" . Q" + S @GL1@("%ut1","CHEKTEST",41)=" QUIT" + S @GL1@("%ut1","CHEKTEST",9)=" S %ut(""ENTN"")=0 ; Number of test, sub to %utUETRY." + S @GL2@("%ut1","ACTLINES")="ACTLINES" + S @GL2@("%ut1","ACTLINES",0)="ACTLINES(GL) ; [Private] $$ ; Count active lines" + S @GL2@("%ut1","ACTLINES",2)=" N CNT S CNT=0" + S @GL2@("%ut1","ACTLINES",3)=" N REF S REF=GL" + S @GL2@("%ut1","ACTLINES",4)=" N GLQL S GLQL=$QL(GL)" + S @GL2@("%ut1","ACTLINES",5)=" F S REF=$Q(@REF) Q:REF="""" Q:(GL'=$NA(@REF,GLQL)) D" + S @GL2@("%ut1","ACTLINES",6)=" . N REFQL S REFQL=$QL(REF)" + S @GL2@("%ut1","ACTLINES",7)=" . N LASTSUB S LASTSUB=$QS(REF,REFQL)" + S @GL2@("%ut1","ACTLINES",8)=" . I LASTSUB?1.N S CNT=CNT+1" + S @GL2@("%ut1","ACTLINES",9)=" QUIT CNT" + S @GL2@("%ut1","CHEKTEST")="CHEKTEST" + S @GL2@("%ut1","CHEKTEST",38)=" . S %ut(""ENTN"")=%ut(""ENTN"")+1,%utUETRY(%ut(""ENTN""))=$P(%ut(""ELIN""),"";"",3),%utUETRY(%ut(""ENTN""),""NAME"")=$P(%ut(""ELIN""),"";"",4)" + S @GL2@("%ut1","CHEKTEST",39)=" . Q" + Q + ; + ; +CACHECOV ;@TEST - set up routine for analysis in globals + N GLOB,GLOBT + S GLOB=$NA(^TMP("%uttcovr1",$J)),GLOBT=$NA(@GLOB@("uttcovr2",$J)) K @GLOB,@GLOBT + D CACHECOV^%ut1(GLOB,GLOBT) + D CHKEQ($T(+1^%ut),@GLOB@("%ut",1,0),"BAD FIRST LINE LOADED FOR %ut") + D CHKEQ($T(+14^%ut),@GLOBT@("%ut",14,0),"Bad 14th line loaded for %ut") + K @GLOB,@GLOBT + Q + ; +GETVALS ; no test - primarily calls to Cache classes + Q + ; +LINEDATA ; @TEST - convert code line to based on tags and offset, and identify active code lines + N CODE,LINE,OFFSET,TAG + S LINE="TEST1 ; COMMENT ON TAG",TAG="",OFFSET=0 + S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ; + D CHKEQ(0,CODE,"Tag with comment identified as active code") + D CHKEQ("TEST1",TAG,"Bad tag returned for TEST1") + D CHKEQ(0,OFFSET,"Bad OFFSET returned for TEST1") + ; + S LINE=" ; COMMENT ONLY" + S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ; + D CHKEQ(0,CODE,"Comment line identified as active code") + D CHKEQ("TEST1",TAG,"Bad tag returned for TEST1+1") + D CHKEQ(1,OFFSET,"Bad OFFSET returned for TEST1+1") + ; + S LINE=" S X=VALUE" + S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ; + D CHKEQ(1,CODE,"Code line NOT identified as active code") + D CHKEQ("TEST1",TAG,"Bad tag returned for TEST1+2") + D CHKEQ(2,OFFSET,"Bad OFFSET returned for TEST1+2") + ; + S LINE="TEST2 S X=VALUE" + S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ; + D CHKEQ(1,CODE,"Tag line with code NOT identified as active code") + D CHKEQ("TEST2",TAG,"Bad tag returned for TEST2") + D CHKEQ(0,OFFSET,"Bad OFFSET returned for TEST2") + ; + Q + ; +TOTAGS ;@TEST - convert from lines of code by line number to lines ordered by tag, line from tag, and only not covered + N ACTIVE,GLOB,GLOBT,X1,X0 + S GLOB=$NA(^TMP("%uttcovr",$J)),GLOBT=$NA(@GLOB@("TEST1")) K @GLOB + S @GLOBT@(1,0)="LINE1 ; CODE1 LINE1+0 NOT ACTIVE" + S @GLOBT@(2,0)=" CODE2 LINE+1 SEEN" + S @GLOBT@(2,"C")=2 + S @GLOBT@(3,0)=" CODE3 LINE1+2 NOT SEEN" + S @GLOBT@(4,0)="LINE4 CODE4 LINE4+0 SEEN" + S @GLOBT@(4,"C")=5 + S @GLOBT@(5,0)=" ; CODE5 LINE4+1 NOT ACTIVE" + S @GLOBT@(6,0)=" CODE6 LINE4+2 COVERED" + S @GLOBT@(6,"C")=2 + S @GLOBT@(7,0)="LINE7 CODE7 LINE7+0 NOT COVERED" + S @GLOBT@(8,0)=" CODE8 LINE7+1 NOT COVERED" + S ACTIVE=1 + D TOTAGS^%ut1(GLOB,ACTIVE) + D CHKEQ(1,($D(@GLOBT@("LINE1"))#2),"LINE1 TAG NOT IDENTIFIED") + D CHKEQ(1,($D(@GLOBT@("LINE4"))#2),"LINE4 TAG NOT IDENTIFIED") + D CHKEQ(1,($D(@GLOBT@("LINE7"))#2),"LINE7 TAG NOT IDENTIFIED") + D CHKEQ(0,$D(@GLOBT@("LINE1",0)),"LINE1+0 SHOULD NOT BE INCLUDED - IT IS A COMMENT") + D CHKEQ(0,$D(@GLOBT@("LINE1",1)),"LINE1+1 SHOULD NOT BE INCLUDED - IT WAS COVERED") + D CHKEQ(1,$D(@GLOBT@("LINE1",2)),"LINE1+2 SHOULD BE INCLUDED - IT WAS NOT COVERED") + D CHKEQ(0,$D(@GLOBT@("LINE4",0)),"LINE4+0 SHOULD NOT BE INCLUDED - IT WAS COVERED") + D CHKEQ(0,$D(@GLOBT@("LINE4",1)),"LINE4+1 SHOULD NOT BE INCLUDED - IT IS A COMMENT") + D CHKEQ(0,$D(@GLOBT@("LINE4",2)),"LINE4+2 SHOULD NOT BE INCLUDED - IT WAS COVERED") + D CHKEQ(1,$D(@GLOBT@("LINE7",0)),"LINE7+0 SHOULD BE INCLUDED - IT IS NOT COVERED") + D CHKEQ(1,$D(@GLOBT@("LINE7",1)),"LINE7+1 SHOULD BE INCLUDED - IT IS NOT COVERED") + K @GLOB,@GLOBT + Q + ; +CHKEQ(EXPECTED,SEEN,COMMENT) ; + D CHKEQ^%ut(EXPECTED,SEEN,$G(COMMENT)) + Q + ; +CHKTF(VALUE,COMMENT) ; + D CHKTF^%ut(VALUE,$G(COMMENT)) + Q