PXVRPC7 ;BPFO/LMT - PCE RPCs for V Immunization ;07/12/16 14:44
;;1.0;PCE PATIENT CARE ENCOUNTER;**216**;Aug 12, 1996;Build 11
;
;
; Reference to ENCODE^VPRJSON supported by ICR #6411
;
RPC(PXRSLT,PXFILTER,PXLIST,PXBEFORE,PXDEM) ; entry point for RPC
;
; Returns immunization records from the V Immunization and V Immunization Deleted file.
; There are two methods for defining the criteria to determine which records to return.
;
; 1. A specific list of record IENs can be passed in, and only those records will
; be returned (if they exist on the system). When called in this way, the list
; of records should be passed in PXLIST, and PXFILTER should not be defined (if
; both PXLIST and PXFILTER are defined, only the records listed in PXLIST will
; be returned, and the search criteria in PXFILTER will be ignored).
;
; If an invalid IEN was passed in, the following error will be returned:
; "Record with IEN #xxx does not exist."
; If the record could not be returned for some other reason, the following
; error will be returned:
; "Unable to return record with IEN #xxx."
;
; 2. A time range (and other filter criteria) can be passed in PXFILTER, and a list
; of records that meet that criteria will be returned. Any record added, edited,
; or deleted (if PXFILTER("INC DELETE")=1) within that time range will be
; returned.
;
; To limit the number of records returned, PXFILTER("MAX") can be set to the maximum
; number of records to be returned. The RPC will return a value called "Bookmark".
; That value can be used to call the RPC again, this time passing in the "Boomark"
; value in PXFILTER("BOOKMARK") (all other parameters should be defined exactly as when
; previously called), and the RPC will return the next n number of records that meet
; the search criteria, and starting where the previous call left off. So for example,
; if there are 1,000 records that meet the search criteria, and PXFILTER("MAX") is
; set to return a maximum of 100 records, the RPC will need to be called 10 times in
; order to return all 1,000 records. Each subsequent time the RPC is called, the caller
; would set PXFILTER("BOOKMARK") to the bookmark value returned in the previous call.
; The caller would know when they reach the end and that there are no more records
; to be returned, when the RPC returns TOTAL ITEMS=0.
;
; Note: All date/time references are to be in FileMan format.
;
;Input:
; PXRSLT - Return value passed by reference (Required)
; PXFILTER - Search criteria (Optional)
; ("START") - Start date/time to begin search from (Defaults to T-1)
; ("STOP") - Stop date/time to end search (if time is not specified,
; midnight is assumed). (Defaults to T-1)
; ("DATA SRC EXC") - A semi-colon delimited list of Data Source names (in external format)
; (e.g., SRC1;SRC2;SRCn) (Optional).
; Any immunization record whose DATA SOURCE matches one of the data names
; in this list will be filtered out, and will not be returned.
; ("MAX") - The maximum number of records to return (defaults to 99)
; ("BOOKMARK") - If wanting to get the next n number of records, the
; bookmark value returned in the previous call should be passed here. (Optional)
; ("INC DELETE") - Flag to control if records should also be returned from the V
; IMMUNIZATION DELETED file. (defaults to "1")
; 1 - Include records from both the V IMMUNIZATION and V IMMUNIZATION DELETED files
; 0 - Only include records from the V IMMUNIZATION file.
; PXLIST - A list of record numbers (IENs) to return (Optional)
; To specify an IEN from the V IMMUNIZATION file, set PXLIST(IEN)=""
; To specify an IEN from the V IMMUNIZATION DELETED file, set PXLIST(IEN_"D")="" (e.g., PXLIST("123D")="")
; PXBEFORE - A date in FileMan format (Optional)
; It is used when the caller wants to see how the records being returned changed since that date. When
; populated, it is used in a number of ways:
; 1. Additions: If a record was added after that date, and later edited, we will
; return the record as if it's a new record (i.e., TYPE="ADD") (even though it's truly an
; edited record), as from that date's perspective this is a new record.
; 2. Edits: a) We will return two versions of an edited record. One, will
; be the way the record existed on that date (i.e., TYPE="UPDATE-BEFORE"). Two, will be the
; current state of the record (i.e., TYPE="UPDATE-AFTER"). b) if no significant changes have been made to this record since
; that date (i.e., the record was edited after that date, but none of the fields that are returned
; in this call were modified with that edit), then we will not return this record, as nothing
; significant changed since that date.
; 3. Deletes: a) If a record was added after that date and later deleted, we won't return the record,
; as on that date the record did not exist, and the current record is deleted, so nothing
; really changed since that date. b) If a record was edited after that date and then deleted,
; the deleted record will be returned the way it existed on that date, as from that date's perspective
; that is what the deleted record looked like.
; PXDEM - Return patient demographics? (1=Yes/0=No) (Defaults to "1").
;
; Currently only JSON is supported.
; PXFORMAT - In what format to return the data "JSON"/"DELIMITED". (Defaults to "JSON")
;
;Returns:
; Each item returned will contain an immunization object, and if demographics are requested, a patient object.
;
; The immunization object can be called: IMM-ADD, IMM-DELETE, IMM-UPDATE, IMM-UPDATE-BEFORE, or IMM-UPDATE-AFTER.
; IMM-ADD - Used when the immunization record is a "new" record.
; IMM-DELETE - Used when the immunizatin record is a deleted record.
; IMM-UPDATE - Used wehn the immunizatin record was edited (and the caller did not pass in a date).
; IMM-UPDATE-BEFORE/IMM-UPDATE-AFTER - Used when the immunizatin record was edited and the called passed in a date.
; Two objects will be returned. The IMM-UPDATE-BEFORE object will be the way the record existed before that date,
; and the IMM-UPDATE-AFTER will be the current state of the record.
;
; For more details on the fields and attributes of the immunization and patient objects, please see the documentation.
;
N DFN,PXBOOKMARK,PXBYLIST,PXCNT,PXDATASRC,PXERRCNT,PXEXDS,PXFILE,PXI,PXINCDEL,PXMAX,PXNEWBOOKMARK,PXSTART,PXSTOP,PXTIME,PXVIMM,PXX
N PXFORMAT ; currently, only JSON is supported. But in the future, perhaps change this to a paramater and also support other formats.
;
S PXRSLT=$NA(^TMP("PXVRPC7-R",$J))
K ^TMP("PXVRPC7",$J),^TMP("PXVRPC7-R",$J)
;
I $G(PXFORMAT)'?1(1"JSON",1"DELIMITED") S PXFORMAT="JSON"
I $G(PXDEM)'?1(1"0",1"1") S PXDEM=1
S PXBEFORE=$G(PXBEFORE)
;
S PXCNT=0
S PXERRCNT=0
;
S PXBYLIST=0
I $O(PXLIST(""))'="" S PXBYLIST=1
;
S PXBEFORE=$G(PXBEFORE)
;
S PXI=""
I PXBYLIST F S PXI=$O(PXLIST(PXI)) Q:PXI="" D
. S PXVIMM=+PXI
. I 'PXVIMM D Q
. . S PXERRCNT=PXERRCNT+1
. . S ^TMP("PXVRPC7",$J,"ERRORS",PXERRCNT)="Record with IEN #"_PXI_" does not exist."
. S PXFILE=$E(PXI,$L(PXI))
. S PXFILE=$S(PXFILE="D":9000080.11,1:9000010.11)
. I PXFILE=9000010.11,'$D(^AUPNVIMM(PXVIMM,0)) D Q
. . S PXERRCNT=PXERRCNT+1
. . S ^TMP("PXVRPC7",$J,"ERRORS",PXERRCNT)="Record with IEN #"_PXI_" does not exist."
. I PXFILE=9000080.11,'$D(^AUPDVIMM(PXVIMM,0)) D Q
. . S PXERRCNT=PXERRCNT+1
. . S ^TMP("PXVRPC7",$J,"ERRORS",PXERRCNT)="Record with IEN #"_PXI_" does not exist."
. I '$$GETREC("PXVRPC7",.PXCNT,PXVIMM,PXFILE,$G(PXDEM),$G(PXBEFORE)) D
. . S PXERRCNT=PXERRCNT+1
. . S ^TMP("PXVRPC7",$J,"ERRORS",PXERRCNT)="Unable to return record with IEN #"_PXI_"."
;
I 'PXBYLIST D
. ;S DFN=$G(PXFILTER("DFN"))
. S PXSTART=$G(PXFILTER("START"))
. I PXSTART="" S PXSTART=$$FMADD^XLFDT(DT,-1)
. S PXSTOP=$G(PXFILTER("STOP"))
. I PXSTOP="" S PXSTOP=$$FMADD^XLFDT(DT,-1)
. I PXSTART,PXSTOP,PXSTOP<PXSTART D
. . S PXX=PXSTART,PXSTART=PXSTOP,PXSTOP=PXX
. I PXSTOP,$P(PXSTOP,".",2)="" S PXSTOP=PXSTOP_".24"
. S PXEXDS=$G(PXFILTER("DATA SRC EXC"))
. F PXX=1:1:99 S PXDATASRC=$P(PXEXDS,";",PXX) Q:PXDATASRC="" S PXEXDS(+$O(^PX(839.7,"B",PXDATASRC,0)))=""
. S PXMAX=+$G(PXFILTER("MAX"))
. I PXMAX'>0 S PXMAX=99
. S PXBOOKMARK=$G(PXFILTER("BOOKMARK"))
. S PXINCDEL=$G(PXFILTER("INC DELETE"))
. I PXINCDEL'?1(1"0",1"1") S PXINCDEL=1
. ;
. S PXTIME=PXSTART-.000000001
. I PXBOOKMARK'="" S PXTIME=$P(PXBOOKMARK,U,1)
. I $P(PXBOOKMARK,U,3)'="D" F S PXTIME=$O(^AUPNVIMM("AT",PXTIME)) Q:('PXTIME)!(PXTIME>PXSTOP)!(PXCNT'<PXMAX) D
. . S PXVIMM=0
. . I PXBOOKMARK'="" S PXVIMM=$P(PXBOOKMARK,U,2) S PXBOOKMARK=""
. . F S PXVIMM=$O(^AUPNVIMM("AT",PXTIME,PXVIMM)) Q:('PXVIMM)!(PXCNT'<PXMAX) D
. . . S PXNEWBOOKMARK=PXTIME_U_PXVIMM
. . . I '$D(^AUPNVIMM(PXVIMM,0)) Q
. . . S PXDATASRC=$P($G(^AUPNVIMM(PXVIMM,812)),U,3)
. . . I $D(PXEXDS(+PXDATASRC)) Q
. . . S PXX=$$GETREC("PXVRPC7",.PXCNT,PXVIMM,9000010.11,$G(PXDEM),$G(PXBEFORE))
. ;
. ; SEARCH DELETED FILE
. S PXTIME=PXSTART-.000000001
. I $P(PXBOOKMARK,U,3)="D" S PXTIME=$P(PXBOOKMARK,U,1)
. I PXINCDEL F S PXTIME=$O(^AUPDVIMM("DD",PXTIME)) Q:('PXTIME)!(PXTIME>PXSTOP)!(PXCNT'<PXMAX) D
. . S PXVIMM=0
. . I $P(PXBOOKMARK,U,3)="D" S PXVIMM=$P(PXBOOKMARK,U,2) S PXBOOKMARK=""
. . F S PXVIMM=$O(^AUPDVIMM("DD",PXTIME,PXVIMM)) Q:('PXVIMM)!(PXCNT'<PXMAX) D
. . . S PXNEWBOOKMARK=PXTIME_U_PXVIMM_U_"D"
. . . I '$D(^AUPDVIMM(PXVIMM,0)) Q
. . . ;if record was added after PXBEFORE, don't include this record
. . . I PXBEFORE,$P($G(^AUPDVIMM(PXVIMM,12)),U,5)>PXBEFORE Q
. . . S PXDATASRC=$P($G(^AUPDVIMM(PXVIMM,812)),U,3)
. . . I $D(PXEXDS(+PXDATASRC)) Q
. . . S PXX=$$GETREC("PXVRPC7",.PXCNT,PXVIMM,9000080.11,$G(PXDEM),$G(PXBEFORE))
;
S ^TMP("PXVRPC7",$J,"FACILITY ID")=$$STA^XUAF4($$KSP^XUPARAM("INST"))
S ^TMP("PXVRPC7",$J,"TOTAL ITEMS")=PXCNT
I 'PXBYLIST S ^TMP("PXVRPC7",$J,"BOOKMARK")=$G(PXNEWBOOKMARK)
;
I $G(PXFORMAT)="JSON" D JSON("PXVRPC7")
;
K ^TMP("PXVRPC7",$J)
;
Q
;
JSON(PXSUB) ; return data in JSON format
;
N PXATT,PXCAT,PXCNT,PXCNT2,PXCODE,PXCODES,PXCODESYS,PXFLD,PXFLDS,PXFLDSUB,PXGBL,PXNODE,PXPIECE,PXSUBTMP,PXTEMP,PXVAL
;
S PXFLDS("IMM","PATIENT")="IEN^NAME"
S PXFLDS("IMM","ORDERING PROVIDER")="IEN^NAME^NPI^VPID"
S PXFLDS("IMM","ENCOUNTER PROVIDER")="IEN^NAME^NPI^VPID"
S PXFLDS("IMM","DOCUMENTER")="IEN^NAME^NPI^VPID"
S PXFLDS("IMM","LOT NUMBER")="IEN^NAME"
S PXFLDS("IMM","MANUFACTURER")="IEN^NAME^MVX CODE"
S PXFLDS("IMM","INFO SOURCE")="IEN^HL7 CODE^NAME"
S PXFLDS("IMM","ADMIN ROUTE")="IEN^HL7 CODE^NAME"
S PXFLDS("IMM","ADMIN SITE")="IEN^HL7 CODE^NAME"
S PXFLDS("IMM","IMMUNIZATION")="IEN^NAME"
S PXFLDS("IMM","DATA SOURCE")="IEN^NAME"
S PXFLDS("IMM","FACILITY")="NAME^STATION NUMBER"
S PXFLDS("IMM","LOCATION")="IEN^NAME"
S PXFLDS("IMM","VIS OFFERED")="IEN^DATE OFFERED^NAME^EDITION DATE^LANGUAGE"
S PXFLDS("PAT","ETHNICITY")="HL7 CODE^NAME"
S PXFLDS("PAT","RACE")="HL7 CODE^NAME"
S PXFLDS("PAT","ADDRESS")="STREET 1^STREET 2^STREET 3^CITY^STATE^ZIP"
S PXFLDS("PAT","SUPPORT")="TYPE^NAME^RELATIONSHIP^PHONE^STREET 1^STREET 2^STREET 3^CITY^STATE^ZIP"
S PXFLDS("PAT","PLACE OF BIRTH")="CITY^STATE"
S PXFLDS("PAT","FACILITY")="NAME^STATION NUMBER"
;
S PXSUBTMP="PXVRPC7-TMP"
K ^TMP(PXSUBTMP,$J)
;
S PXGBL=$NA(^TMP(PXSUB,$J))
F S PXGBL=$Q(@PXGBL) Q:PXGBL="" Q:($QS(PXGBL,1)'=PXSUB)!($QS(PXGBL,2)'=$J) D
. I $QS(PXGBL,3)'="ITEMS" D Q
. . M ^TMP(PXSUBTMP,$J,$QS(PXGBL,3))=^TMP(PXSUB,$J,$QS(PXGBL,3))
. S PXCNT=$QS(PXGBL,4)
. S PXCAT=$QS(PXGBL,5)
. S PXFLD=$QS(PXGBL,6)
. S PXFLDSUB=$S(PXCAT="PATIENT":"PAT",1:"IMM")
. ;
. I PXFLDSUB="IMM",PXFLD="CODES" D Q
. . S PXCODESYS=$QS(PXGBL,7)
. . S PXCODES=@PXGBL
. . K @PXGBL
. . F PXPIECE=1:1:99 S PXCODE=$P(PXCODES,U,PXPIECE) Q:PXCODE="" D
. . . S ^TMP(PXSUBTMP,$J,"ITEMS",PXCNT,PXCAT,"CODING SYSTEM",PXCODESYS,PXPIECE)=PXCODE
. ;
. I PXFLDSUB="IMM",PXFLD="VACCINE GROUP" D Q
. . S PXCNT2=$QS(PXGBL,7)
. . S ^TMP(PXSUBTMP,$J,"ITEMS",PXCNT,PXCAT,"VACCINE GROUPS",PXCNT2)=@PXGBL
. ;
. S PXVAL=$G(PXFLDS(PXFLDSUB,PXFLD))
. I PXVAL="" D Q
. . S ^TMP(PXSUBTMP,$J,"ITEMS",PXCNT,PXCAT,PXFLD)=@PXGBL
. S PXTEMP=@PXGBL
. K @PXGBL
. S PXCNT2=$QS(PXGBL,7)
. S PXNODE=$NA(^TMP(PXSUBTMP,$J,"ITEMS",PXCNT,PXCAT,PXFLD))
. F PXPIECE=1:1:99 S PXATT=$P(PXVAL,U,PXPIECE) Q:PXATT="" D
. . I PXCNT2>0 S @PXNODE@(PXCNT2,PXATT)=$P(PXTEMP,U,PXPIECE)
. . I PXCNT2'>0 S @PXNODE@(PXATT)=$P(PXTEMP,U,PXPIECE)
;
D ENCODE^VPRJSON("^TMP("""_PXSUBTMP_""",$J)","^TMP("""_PXSUB_"-R"",$J)") ;ICR 6411
;
K ^TMP(PXSUBTMP,$J)
;
Q
;
GETREC(PXSUB,PXCNT,PXVIMM,PXFILE,PXGETDEM,PXDATE) ; get one record and add it to ^TMP
;
N DFN,PXADDDT,PXEDITED,PXIMMNODE,PXPATARR,PXRSLT,PXTYPE,PXVALID,PXVIMMARR
;
;shold we return this record as an add, update, or delete
S PXTYPE=$S(PXFILE=9000080.11:"D",1:"A")
I PXFILE=9000010.11 D
. S PXADDDT=$P($G(^AUPNVIMM(PXVIMM,12)),U,5)
. ;if record as added after PXDATE, treat it as an A, even if it was editted
. I PXDATE,PXADDDT>PXDATE Q
. S PXEDITED=$P($G(^AUPNVIMM(PXVIMM,801)),U,1)
. I PXEDITED=1 S PXTYPE="U" ; EDITED FLAG
;
; For updates, when PXDATE is defined, send before/after
I PXTYPE="U",PXDATE S PXTYPE="UBA"
;
S PXCNT=PXCNT+1
;
I PXTYPE="UBA" D
. D VIMM^PXVRPC7A(.PXVIMMARR,PXVIMM,PXFILE,PXDATE)
. I '$$VALIDATE(.PXVIMMARR) D Q
. . S PXTYPE="A"
. M ^TMP(PXSUB,$J,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")=PXVIMMARR
;
S PXIMMNODE=$S(PXTYPE="A":"IMM-ADD",PXTYPE="D":"IMM-DELETE",PXTYPE="U":"IMM-UPDATE",1:"IMM-UPDATE-AFTER")
;for IMM-ADD and IMM-UPDATE-AFTER, we want to get the current state of the record.
I PXTYPE'="D" S PXDATE=""
S PXRSLT=$NA(^TMP(PXSUB,$J,"ITEMS",PXCNT,PXIMMNODE))
K PXVIMMARR
D VIMM^PXVRPC7A(.PXVIMMARR,PXVIMM,PXFILE,PXDATE)
S PXVALID=$$VALIDATE(.PXVIMMARR)
I 'PXVALID,PXTYPE="UBA",$D(^TMP(PXSUB,$J,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")) D
. S PXTYPE="D"
. S PXIMMNODE="IMM-DELETE"
. M ^TMP(PXSUB,$J,"ITEMS",PXCNT,PXIMMNODE)=^TMP(PXSUB,$J,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")
. K ^TMP(PXSUB,$J,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")
;
I PXVALID M ^TMP(PXSUB,$J,"ITEMS",PXCNT,PXIMMNODE)=PXVIMMARR
I '$D(^TMP(PXSUB,$J,"ITEMS",PXCNT)) D Q 0
. S PXCNT=PXCNT-1
;
; for edits, compare before/after. if nothing changed, don't include this record.
I PXTYPE="UBA",$$COMPARE(PXSUB,PXCNT,"IMM-UPDATE-BEFORE","IMM-UPDATE-AFTER") D Q 0
. K ^TMP(PXSUB,$J,"ITEMS",PXCNT)
. S PXCNT=PXCNT-1
;
S DFN=+$G(^TMP(PXSUB,$J,"ITEMS",PXCNT,PXIMMNODE,"PATIENT"))
I DFN,$G(PXGETDEM) D
. ;K ^TMP(PXSUB,$J,PXCNT,PXIMMNODE,"PATIENT")
. D DEM^PXVRPC7A(.PXPATARR,DFN)
. M ^TMP(PXSUB,$J,"ITEMS",PXCNT,"PATIENT")=PXPATARR
Q 1
;
VALIDATE(PXVIMMARR) ;validate immun record has minimum fields populated
I '$G(PXVIMMARR("PATIENT")) Q 0
I '$D(^DPT(+PXVIMMARR("PATIENT"),0)) Q 0
I '$G(PXVIMMARR("ADMINISTERED DATE TIME")) Q 0
I '$G(PXVIMMARR("IMMUNIZATION")) Q 0
Q 1
;
COMPARE(PXSUB,PXCNT,PXSUB1,PXSUB2) ;
; Compare the two arryas (PXSUB1 and PXSUB2).
; Returns 1 - If they are equal
; 0 - if they are not equal
;
N PXGBL,PXGBL2,PXNUM,PXRSLT,PXX
;
S PXRSLT=1
;
S PXGBL=$NA(^TMP(PXSUB,$J,"ITEMS",PXCNT,PXSUB1))
F S PXGBL=$Q(@PXGBL) Q:(PXGBL="")!('PXRSLT) Q:($QS(PXGBL,1)'=PXSUB)!($QS(PXGBL,2)'=$J)!($QS(PXGBL,3)'="ITEMS")!($QS(PXGBL,4)'=PXCNT)!($QS(PXGBL,5)'=PXSUB1) D
. S PXGBL2="^TMP("
. S PXNUM=$QL(PXGBL)
. F PXX=1:1:PXNUM D
. . I PXX=5 D Q
. . . S PXGBL2=PXGBL2_","""_PXSUB2_""""
. . S PXGBL2=PXGBL2_$S(PXX=1:"",1:",")_""""_$QS(PXGBL,PXX)_""""
. S PXGBL2=PXGBL2_")"
. I $G(@PXGBL)'=$G(@PXGBL2) S PXRSLT=0
;
Q PXRSLT
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXVRPC7 16514 printed Nov 22, 2024@17:42:04 Page 2
PXVRPC7 ;BPFO/LMT - PCE RPCs for V Immunization ;07/12/16 14:44
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**216**;Aug 12, 1996;Build 11
+2 ;
+3 ;
+4 ; Reference to ENCODE^VPRJSON supported by ICR #6411
+5 ;
RPC(PXRSLT,PXFILTER,PXLIST,PXBEFORE,PXDEM) ; entry point for RPC
+1 ;
+2 ; Returns immunization records from the V Immunization and V Immunization Deleted file.
+3 ; There are two methods for defining the criteria to determine which records to return.
+4 ;
+5 ; 1. A specific list of record IENs can be passed in, and only those records will
+6 ; be returned (if they exist on the system). When called in this way, the list
+7 ; of records should be passed in PXLIST, and PXFILTER should not be defined (if
+8 ; both PXLIST and PXFILTER are defined, only the records listed in PXLIST will
+9 ; be returned, and the search criteria in PXFILTER will be ignored).
+10 ;
+11 ; If an invalid IEN was passed in, the following error will be returned:
+12 ; "Record with IEN #xxx does not exist."
+13 ; If the record could not be returned for some other reason, the following
+14 ; error will be returned:
+15 ; "Unable to return record with IEN #xxx."
+16 ;
+17 ; 2. A time range (and other filter criteria) can be passed in PXFILTER, and a list
+18 ; of records that meet that criteria will be returned. Any record added, edited,
+19 ; or deleted (if PXFILTER("INC DELETE")=1) within that time range will be
+20 ; returned.
+21 ;
+22 ; To limit the number of records returned, PXFILTER("MAX") can be set to the maximum
+23 ; number of records to be returned. The RPC will return a value called "Bookmark".
+24 ; That value can be used to call the RPC again, this time passing in the "Boomark"
+25 ; value in PXFILTER("BOOKMARK") (all other parameters should be defined exactly as when
+26 ; previously called), and the RPC will return the next n number of records that meet
+27 ; the search criteria, and starting where the previous call left off. So for example,
+28 ; if there are 1,000 records that meet the search criteria, and PXFILTER("MAX") is
+29 ; set to return a maximum of 100 records, the RPC will need to be called 10 times in
+30 ; order to return all 1,000 records. Each subsequent time the RPC is called, the caller
+31 ; would set PXFILTER("BOOKMARK") to the bookmark value returned in the previous call.
+32 ; The caller would know when they reach the end and that there are no more records
+33 ; to be returned, when the RPC returns TOTAL ITEMS=0.
+34 ;
+35 ; Note: All date/time references are to be in FileMan format.
+36 ;
+37 ;Input:
+38 ; PXRSLT - Return value passed by reference (Required)
+39 ; PXFILTER - Search criteria (Optional)
+40 ; ("START") - Start date/time to begin search from (Defaults to T-1)
+41 ; ("STOP") - Stop date/time to end search (if time is not specified,
+42 ; midnight is assumed). (Defaults to T-1)
+43 ; ("DATA SRC EXC") - A semi-colon delimited list of Data Source names (in external format)
+44 ; (e.g., SRC1;SRC2;SRCn) (Optional).
+45 ; Any immunization record whose DATA SOURCE matches one of the data names
+46 ; in this list will be filtered out, and will not be returned.
+47 ; ("MAX") - The maximum number of records to return (defaults to 99)
+48 ; ("BOOKMARK") - If wanting to get the next n number of records, the
+49 ; bookmark value returned in the previous call should be passed here. (Optional)
+50 ; ("INC DELETE") - Flag to control if records should also be returned from the V
+51 ; IMMUNIZATION DELETED file. (defaults to "1")
+52 ; 1 - Include records from both the V IMMUNIZATION and V IMMUNIZATION DELETED files
+53 ; 0 - Only include records from the V IMMUNIZATION file.
+54 ; PXLIST - A list of record numbers (IENs) to return (Optional)
+55 ; To specify an IEN from the V IMMUNIZATION file, set PXLIST(IEN)=""
+56 ; To specify an IEN from the V IMMUNIZATION DELETED file, set PXLIST(IEN_"D")="" (e.g., PXLIST("123D")="")
+57 ; PXBEFORE - A date in FileMan format (Optional)
+58 ; It is used when the caller wants to see how the records being returned changed since that date. When
+59 ; populated, it is used in a number of ways:
+60 ; 1. Additions: If a record was added after that date, and later edited, we will
+61 ; return the record as if it's a new record (i.e., TYPE="ADD") (even though it's truly an
+62 ; edited record), as from that date's perspective this is a new record.
+63 ; 2. Edits: a) We will return two versions of an edited record. One, will
+64 ; be the way the record existed on that date (i.e., TYPE="UPDATE-BEFORE"). Two, will be the
+65 ; current state of the record (i.e., TYPE="UPDATE-AFTER"). b) if no significant changes have been made to this record since
+66 ; that date (i.e., the record was edited after that date, but none of the fields that are returned
+67 ; in this call were modified with that edit), then we will not return this record, as nothing
+68 ; significant changed since that date.
+69 ; 3. Deletes: a) If a record was added after that date and later deleted, we won't return the record,
+70 ; as on that date the record did not exist, and the current record is deleted, so nothing
+71 ; really changed since that date. b) If a record was edited after that date and then deleted,
+72 ; the deleted record will be returned the way it existed on that date, as from that date's perspective
+73 ; that is what the deleted record looked like.
+74 ; PXDEM - Return patient demographics? (1=Yes/0=No) (Defaults to "1").
+75 ;
+76 ; Currently only JSON is supported.
+77 ; PXFORMAT - In what format to return the data "JSON"/"DELIMITED". (Defaults to "JSON")
+78 ;
+79 ;Returns:
+80 ; Each item returned will contain an immunization object, and if demographics are requested, a patient object.
+81 ;
+82 ; The immunization object can be called: IMM-ADD, IMM-DELETE, IMM-UPDATE, IMM-UPDATE-BEFORE, or IMM-UPDATE-AFTER.
+83 ; IMM-ADD - Used when the immunization record is a "new" record.
+84 ; IMM-DELETE - Used when the immunizatin record is a deleted record.
+85 ; IMM-UPDATE - Used wehn the immunizatin record was edited (and the caller did not pass in a date).
+86 ; IMM-UPDATE-BEFORE/IMM-UPDATE-AFTER - Used when the immunizatin record was edited and the called passed in a date.
+87 ; Two objects will be returned. The IMM-UPDATE-BEFORE object will be the way the record existed before that date,
+88 ; and the IMM-UPDATE-AFTER will be the current state of the record.
+89 ;
+90 ; For more details on the fields and attributes of the immunization and patient objects, please see the documentation.
+91 ;
+92 NEW DFN,PXBOOKMARK,PXBYLIST,PXCNT,PXDATASRC,PXERRCNT,PXEXDS,PXFILE,PXI,PXINCDEL,PXMAX,PXNEWBOOKMARK,PXSTART,PXSTOP,PXTIME,PXVIMM,PXX
+93 ; currently, only JSON is supported. But in the future, perhaps change this to a paramater and also support other formats.
NEW PXFORMAT
+94 ;
+95 SET PXRSLT=$NAME(^TMP("PXVRPC7-R",$JOB))
+96 KILL ^TMP("PXVRPC7",$JOB),^TMP("PXVRPC7-R",$JOB)
+97 ;
+98 IF $GET(PXFORMAT)'?1(1"JSON",1"DELIMITED")
SET PXFORMAT="JSON"
+99 IF $GET(PXDEM)'?1(1"0",1"1")
SET PXDEM=1
+100 SET PXBEFORE=$GET(PXBEFORE)
+101 ;
+102 SET PXCNT=0
+103 SET PXERRCNT=0
+104 ;
+105 SET PXBYLIST=0
+106 IF $ORDER(PXLIST(""))'=""
SET PXBYLIST=1
+107 ;
+108 SET PXBEFORE=$GET(PXBEFORE)
+109 ;
+110 SET PXI=""
+111 IF PXBYLIST
FOR
SET PXI=$ORDER(PXLIST(PXI))
if PXI=""
QUIT
Begin DoDot:1
+112 SET PXVIMM=+PXI
+113 IF 'PXVIMM
Begin DoDot:2
+114 SET PXERRCNT=PXERRCNT+1
+115 SET ^TMP("PXVRPC7",$JOB,"ERRORS",PXERRCNT)="Record with IEN #"_PXI_" does not exist."
End DoDot:2
QUIT
+116 SET PXFILE=$EXTRACT(PXI,$LENGTH(PXI))
+117 SET PXFILE=$SELECT(PXFILE="D":9000080.11,1:9000010.11)
+118 IF PXFILE=9000010.11
IF '$DATA(^AUPNVIMM(PXVIMM,0))
Begin DoDot:2
+119 SET PXERRCNT=PXERRCNT+1
+120 SET ^TMP("PXVRPC7",$JOB,"ERRORS",PXERRCNT)="Record with IEN #"_PXI_" does not exist."
End DoDot:2
QUIT
+121 IF PXFILE=9000080.11
IF '$DATA(^AUPDVIMM(PXVIMM,0))
Begin DoDot:2
+122 SET PXERRCNT=PXERRCNT+1
+123 SET ^TMP("PXVRPC7",$JOB,"ERRORS",PXERRCNT)="Record with IEN #"_PXI_" does not exist."
End DoDot:2
QUIT
+124 IF '$$GETREC("PXVRPC7",.PXCNT,PXVIMM,PXFILE,$GET(PXDEM),$GET(PXBEFORE))
Begin DoDot:2
+125 SET PXERRCNT=PXERRCNT+1
+126 SET ^TMP("PXVRPC7",$JOB,"ERRORS",PXERRCNT)="Unable to return record with IEN #"_PXI_"."
End DoDot:2
End DoDot:1
+127 ;
+128 IF 'PXBYLIST
Begin DoDot:1
+129 ;S DFN=$G(PXFILTER("DFN"))
+130 SET PXSTART=$GET(PXFILTER("START"))
+131 IF PXSTART=""
SET PXSTART=$$FMADD^XLFDT(DT,-1)
+132 SET PXSTOP=$GET(PXFILTER("STOP"))
+133 IF PXSTOP=""
SET PXSTOP=$$FMADD^XLFDT(DT,-1)
+134 IF PXSTART
IF PXSTOP
IF PXSTOP<PXSTART
Begin DoDot:2
+135 SET PXX=PXSTART
SET PXSTART=PXSTOP
SET PXSTOP=PXX
End DoDot:2
+136 IF PXSTOP
IF $PIECE(PXSTOP,".",2)=""
SET PXSTOP=PXSTOP_".24"
+137 SET PXEXDS=$GET(PXFILTER("DATA SRC EXC"))
+138 FOR PXX=1:1:99
SET PXDATASRC=$PIECE(PXEXDS,";",PXX)
if PXDATASRC=""
QUIT
SET PXEXDS(+$ORDER(^PX(839.7,"B",PXDATASRC,0)))=""
+139 SET PXMAX=+$GET(PXFILTER("MAX"))
+140 IF PXMAX'>0
SET PXMAX=99
+141 SET PXBOOKMARK=$GET(PXFILTER("BOOKMARK"))
+142 SET PXINCDEL=$GET(PXFILTER("INC DELETE"))
+143 IF PXINCDEL'?1(1"0",1"1")
SET PXINCDEL=1
+144 ;
+145 SET PXTIME=PXSTART-.000000001
+146 IF PXBOOKMARK'=""
SET PXTIME=$PIECE(PXBOOKMARK,U,1)
+147 IF $PIECE(PXBOOKMARK,U,3)'="D"
FOR
SET PXTIME=$ORDER(^AUPNVIMM("AT",PXTIME))
if ('PXTIME)!(PXTIME>PXSTOP)!(PXCNT'<PXMAX)
QUIT
Begin DoDot:2
+148 SET PXVIMM=0
+149 IF PXBOOKMARK'=""
SET PXVIMM=$PIECE(PXBOOKMARK,U,2)
SET PXBOOKMARK=""
+150 FOR
SET PXVIMM=$ORDER(^AUPNVIMM("AT",PXTIME,PXVIMM))
if ('PXVIMM)!(PXCNT'<PXMAX)
QUIT
Begin DoDot:3
+151 SET PXNEWBOOKMARK=PXTIME_U_PXVIMM
+152 IF '$DATA(^AUPNVIMM(PXVIMM,0))
QUIT
+153 SET PXDATASRC=$PIECE($GET(^AUPNVIMM(PXVIMM,812)),U,3)
+154 IF $DATA(PXEXDS(+PXDATASRC))
QUIT
+155 SET PXX=$$GETREC("PXVRPC7",.PXCNT,PXVIMM,9000010.11,$GET(PXDEM),$GET(PXBEFORE))
End DoDot:3
End DoDot:2
+156 ;
+157 ; SEARCH DELETED FILE
+158 SET PXTIME=PXSTART-.000000001
+159 IF $PIECE(PXBOOKMARK,U,3)="D"
SET PXTIME=$PIECE(PXBOOKMARK,U,1)
+160 IF PXINCDEL
FOR
SET PXTIME=$ORDER(^AUPDVIMM("DD",PXTIME))
if ('PXTIME)!(PXTIME>PXSTOP)!(PXCNT'<PXMAX)
QUIT
Begin DoDot:2
+161 SET PXVIMM=0
+162 IF $PIECE(PXBOOKMARK,U,3)="D"
SET PXVIMM=$PIECE(PXBOOKMARK,U,2)
SET PXBOOKMARK=""
+163 FOR
SET PXVIMM=$ORDER(^AUPDVIMM("DD",PXTIME,PXVIMM))
if ('PXVIMM)!(PXCNT'<PXMAX)
QUIT
Begin DoDot:3
+164 SET PXNEWBOOKMARK=PXTIME_U_PXVIMM_U_"D"
+165 IF '$DATA(^AUPDVIMM(PXVIMM,0))
QUIT
+166 ;if record was added after PXBEFORE, don't include this record
+167 IF PXBEFORE
IF $PIECE($GET(^AUPDVIMM(PXVIMM,12)),U,5)>PXBEFORE
QUIT
+168 SET PXDATASRC=$PIECE($GET(^AUPDVIMM(PXVIMM,812)),U,3)
+169 IF $DATA(PXEXDS(+PXDATASRC))
QUIT
+170 SET PXX=$$GETREC("PXVRPC7",.PXCNT,PXVIMM,9000080.11,$GET(PXDEM),$GET(PXBEFORE))
End DoDot:3
End DoDot:2
End DoDot:1
+171 ;
+172 SET ^TMP("PXVRPC7",$JOB,"FACILITY ID")=$$STA^XUAF4($$KSP^XUPARAM("INST"))
+173 SET ^TMP("PXVRPC7",$JOB,"TOTAL ITEMS")=PXCNT
+174 IF 'PXBYLIST
SET ^TMP("PXVRPC7",$JOB,"BOOKMARK")=$GET(PXNEWBOOKMARK)
+175 ;
+176 IF $GET(PXFORMAT)="JSON"
DO JSON("PXVRPC7")
+177 ;
+178 KILL ^TMP("PXVRPC7",$JOB)
+179 ;
+180 QUIT
+181 ;
JSON(PXSUB) ; return data in JSON format
+1 ;
+2 NEW PXATT,PXCAT,PXCNT,PXCNT2,PXCODE,PXCODES,PXCODESYS,PXFLD,PXFLDS,PXFLDSUB,PXGBL,PXNODE,PXPIECE,PXSUBTMP,PXTEMP,PXVAL
+3 ;
+4 SET PXFLDS("IMM","PATIENT")="IEN^NAME"
+5 SET PXFLDS("IMM","ORDERING PROVIDER")="IEN^NAME^NPI^VPID"
+6 SET PXFLDS("IMM","ENCOUNTER PROVIDER")="IEN^NAME^NPI^VPID"
+7 SET PXFLDS("IMM","DOCUMENTER")="IEN^NAME^NPI^VPID"
+8 SET PXFLDS("IMM","LOT NUMBER")="IEN^NAME"
+9 SET PXFLDS("IMM","MANUFACTURER")="IEN^NAME^MVX CODE"
+10 SET PXFLDS("IMM","INFO SOURCE")="IEN^HL7 CODE^NAME"
+11 SET PXFLDS("IMM","ADMIN ROUTE")="IEN^HL7 CODE^NAME"
+12 SET PXFLDS("IMM","ADMIN SITE")="IEN^HL7 CODE^NAME"
+13 SET PXFLDS("IMM","IMMUNIZATION")="IEN^NAME"
+14 SET PXFLDS("IMM","DATA SOURCE")="IEN^NAME"
+15 SET PXFLDS("IMM","FACILITY")="NAME^STATION NUMBER"
+16 SET PXFLDS("IMM","LOCATION")="IEN^NAME"
+17 SET PXFLDS("IMM","VIS OFFERED")="IEN^DATE OFFERED^NAME^EDITION DATE^LANGUAGE"
+18 SET PXFLDS("PAT","ETHNICITY")="HL7 CODE^NAME"
+19 SET PXFLDS("PAT","RACE")="HL7 CODE^NAME"
+20 SET PXFLDS("PAT","ADDRESS")="STREET 1^STREET 2^STREET 3^CITY^STATE^ZIP"
+21 SET PXFLDS("PAT","SUPPORT")="TYPE^NAME^RELATIONSHIP^PHONE^STREET 1^STREET 2^STREET 3^CITY^STATE^ZIP"
+22 SET PXFLDS("PAT","PLACE OF BIRTH")="CITY^STATE"
+23 SET PXFLDS("PAT","FACILITY")="NAME^STATION NUMBER"
+24 ;
+25 SET PXSUBTMP="PXVRPC7-TMP"
+26 KILL ^TMP(PXSUBTMP,$JOB)
+27 ;
+28 SET PXGBL=$NAME(^TMP(PXSUB,$JOB))
+29 FOR
SET PXGBL=$QUERY(@PXGBL)
if PXGBL=""
QUIT
if ($QSUBSCRIPT(PXGBL,1)'=PXSUB)!($QSUBSCRIPT(PXGBL,2)'=$JOB)
QUIT
Begin DoDot:1
+30 IF $QSUBSCRIPT(PXGBL,3)'="ITEMS"
Begin DoDot:2
+31 MERGE ^TMP(PXSUBTMP,$JOB,$QSUBSCRIPT(PXGBL,3))=^TMP(PXSUB,$JOB,$QSUBSCRIPT(PXGBL,3))
End DoDot:2
QUIT
+32 SET PXCNT=$QSUBSCRIPT(PXGBL,4)
+33 SET PXCAT=$QSUBSCRIPT(PXGBL,5)
+34 SET PXFLD=$QSUBSCRIPT(PXGBL,6)
+35 SET PXFLDSUB=$SELECT(PXCAT="PATIENT":"PAT",1:"IMM")
+36 ;
+37 IF PXFLDSUB="IMM"
IF PXFLD="CODES"
Begin DoDot:2
+38 SET PXCODESYS=$QSUBSCRIPT(PXGBL,7)
+39 SET PXCODES=@PXGBL
+40 KILL @PXGBL
+41 FOR PXPIECE=1:1:99
SET PXCODE=$PIECE(PXCODES,U,PXPIECE)
if PXCODE=""
QUIT
Begin DoDot:3
+42 SET ^TMP(PXSUBTMP,$JOB,"ITEMS",PXCNT,PXCAT,"CODING SYSTEM",PXCODESYS,PXPIECE)=PXCODE
End DoDot:3
End DoDot:2
QUIT
+43 ;
+44 IF PXFLDSUB="IMM"
IF PXFLD="VACCINE GROUP"
Begin DoDot:2
+45 SET PXCNT2=$QSUBSCRIPT(PXGBL,7)
+46 SET ^TMP(PXSUBTMP,$JOB,"ITEMS",PXCNT,PXCAT,"VACCINE GROUPS",PXCNT2)=@PXGBL
End DoDot:2
QUIT
+47 ;
+48 SET PXVAL=$GET(PXFLDS(PXFLDSUB,PXFLD))
+49 IF PXVAL=""
Begin DoDot:2
+50 SET ^TMP(PXSUBTMP,$JOB,"ITEMS",PXCNT,PXCAT,PXFLD)=@PXGBL
End DoDot:2
QUIT
+51 SET PXTEMP=@PXGBL
+52 KILL @PXGBL
+53 SET PXCNT2=$QSUBSCRIPT(PXGBL,7)
+54 SET PXNODE=$NAME(^TMP(PXSUBTMP,$JOB,"ITEMS",PXCNT,PXCAT,PXFLD))
+55 FOR PXPIECE=1:1:99
SET PXATT=$PIECE(PXVAL,U,PXPIECE)
if PXATT=""
QUIT
Begin DoDot:2
+56 IF PXCNT2>0
SET @PXNODE@(PXCNT2,PXATT)=$PIECE(PXTEMP,U,PXPIECE)
+57 IF PXCNT2'>0
SET @PXNODE@(PXATT)=$PIECE(PXTEMP,U,PXPIECE)
End DoDot:2
End DoDot:1
+58 ;
+59 ;ICR 6411
DO ENCODE^VPRJSON("^TMP("""_PXSUBTMP_""",$J)","^TMP("""_PXSUB_"-R"",$J)")
+60 ;
+61 KILL ^TMP(PXSUBTMP,$JOB)
+62 ;
+63 QUIT
+64 ;
GETREC(PXSUB,PXCNT,PXVIMM,PXFILE,PXGETDEM,PXDATE) ; get one record and add it to ^TMP
+1 ;
+2 NEW DFN,PXADDDT,PXEDITED,PXIMMNODE,PXPATARR,PXRSLT,PXTYPE,PXVALID,PXVIMMARR
+3 ;
+4 ;shold we return this record as an add, update, or delete
+5 SET PXTYPE=$SELECT(PXFILE=9000080.11:"D",1:"A")
+6 IF PXFILE=9000010.11
Begin DoDot:1
+7 SET PXADDDT=$PIECE($GET(^AUPNVIMM(PXVIMM,12)),U,5)
+8 ;if record as added after PXDATE, treat it as an A, even if it was editted
+9 IF PXDATE
IF PXADDDT>PXDATE
QUIT
+10 SET PXEDITED=$PIECE($GET(^AUPNVIMM(PXVIMM,801)),U,1)
+11 ; EDITED FLAG
IF PXEDITED=1
SET PXTYPE="U"
End DoDot:1
+12 ;
+13 ; For updates, when PXDATE is defined, send before/after
+14 IF PXTYPE="U"
IF PXDATE
SET PXTYPE="UBA"
+15 ;
+16 SET PXCNT=PXCNT+1
+17 ;
+18 IF PXTYPE="UBA"
Begin DoDot:1
+19 DO VIMM^PXVRPC7A(.PXVIMMARR,PXVIMM,PXFILE,PXDATE)
+20 IF '$$VALIDATE(.PXVIMMARR)
Begin DoDot:2
+21 SET PXTYPE="A"
End DoDot:2
QUIT
+22 MERGE ^TMP(PXSUB,$JOB,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")=PXVIMMARR
End DoDot:1
+23 ;
+24 SET PXIMMNODE=$SELECT(PXTYPE="A":"IMM-ADD",PXTYPE="D":"IMM-DELETE",PXTYPE="U":"IMM-UPDATE",1:"IMM-UPDATE-AFTER")
+25 ;for IMM-ADD and IMM-UPDATE-AFTER, we want to get the current state of the record.
+26 IF PXTYPE'="D"
SET PXDATE=""
+27 SET PXRSLT=$NAME(^TMP(PXSUB,$JOB,"ITEMS",PXCNT,PXIMMNODE))
+28 KILL PXVIMMARR
+29 DO VIMM^PXVRPC7A(.PXVIMMARR,PXVIMM,PXFILE,PXDATE)
+30 SET PXVALID=$$VALIDATE(.PXVIMMARR)
+31 IF 'PXVALID
IF PXTYPE="UBA"
IF $DATA(^TMP(PXSUB,$JOB,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE"))
Begin DoDot:1
+32 SET PXTYPE="D"
+33 SET PXIMMNODE="IMM-DELETE"
+34 MERGE ^TMP(PXSUB,$JOB,"ITEMS",PXCNT,PXIMMNODE)=^TMP(PXSUB,$JOB,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")
+35 KILL ^TMP(PXSUB,$JOB,"ITEMS",PXCNT,"IMM-UPDATE-BEFORE")
End DoDot:1
+36 ;
+37 IF PXVALID
MERGE ^TMP(PXSUB,$JOB,"ITEMS",PXCNT,PXIMMNODE)=PXVIMMARR
+38 IF '$DATA(^TMP(PXSUB,$JOB,"ITEMS",PXCNT))
Begin DoDot:1
+39 SET PXCNT=PXCNT-1
End DoDot:1
QUIT 0
+40 ;
+41 ; for edits, compare before/after. if nothing changed, don't include this record.
+42 IF PXTYPE="UBA"
IF $$COMPARE(PXSUB,PXCNT,"IMM-UPDATE-BEFORE","IMM-UPDATE-AFTER")
Begin DoDot:1
+43 KILL ^TMP(PXSUB,$JOB,"ITEMS",PXCNT)
+44 SET PXCNT=PXCNT-1
End DoDot:1
QUIT 0
+45 ;
+46 SET DFN=+$GET(^TMP(PXSUB,$JOB,"ITEMS",PXCNT,PXIMMNODE,"PATIENT"))
+47 IF DFN
IF $GET(PXGETDEM)
Begin DoDot:1
+48 ;K ^TMP(PXSUB,$J,PXCNT,PXIMMNODE,"PATIENT")
+49 DO DEM^PXVRPC7A(.PXPATARR,DFN)
+50 MERGE ^TMP(PXSUB,$JOB,"ITEMS",PXCNT,"PATIENT")=PXPATARR
End DoDot:1
+51 QUIT 1
+52 ;
VALIDATE(PXVIMMARR) ;validate immun record has minimum fields populated
+1 IF '$GET(PXVIMMARR("PATIENT"))
QUIT 0
+2 IF '$DATA(^DPT(+PXVIMMARR("PATIENT"),0))
QUIT 0
+3 IF '$GET(PXVIMMARR("ADMINISTERED DATE TIME"))
QUIT 0
+4 IF '$GET(PXVIMMARR("IMMUNIZATION"))
QUIT 0
+5 QUIT 1
+6 ;
COMPARE(PXSUB,PXCNT,PXSUB1,PXSUB2) ;
+1 ; Compare the two arryas (PXSUB1 and PXSUB2).
+2 ; Returns 1 - If they are equal
+3 ; 0 - if they are not equal
+4 ;
+5 NEW PXGBL,PXGBL2,PXNUM,PXRSLT,PXX
+6 ;
+7 SET PXRSLT=1
+8 ;
+9 SET PXGBL=$NAME(^TMP(PXSUB,$JOB,"ITEMS",PXCNT,PXSUB1))
+10 FOR
SET PXGBL=$QUERY(@PXGBL)
if (PXGBL="")!('PXRSLT)
QUIT
if ($QSUBSCRIPT(PXGBL,1)'=PXSUB)!($QSUBSCRIPT(PXGBL,2)'=$JOB)!($QSUBSCRIPT(PXGBL,3)'="ITEMS")!($QSUBSCRIPT(PXGBL,4)'=PXCNT)!($QSUBSCRIPT(PXGBL,5)'=PXSUB1)
QUIT
Begin DoDot:1
+11 SET PXGBL2="^TMP("
+12 SET PXNUM=$QLENGTH(PXGBL)
+13 FOR PXX=1:1:PXNUM
Begin DoDot:2
+14 IF PXX=5
Begin DoDot:3
+15 SET PXGBL2=PXGBL2_","""_PXSUB2_""""
End DoDot:3
QUIT
+16 SET PXGBL2=PXGBL2_$SELECT(PXX=1:"",1:",")_""""_$QSUBSCRIPT(PXGBL,PXX)_""""
End DoDot:2
+17 SET PXGBL2=PXGBL2_")"
+18 IF $GET(@PXGBL)'=$GET(@PXGBL2)
SET PXRSLT=0
End DoDot:1
+19 ;
+20 QUIT PXRSLT
+21 ;