CIAZGRPC ;MSC/IND/DKM - Generic Retrieval RPC's;09-Dec-2011 10:12;PLS
;;1.4;GENERIC RETRIEVAL UTILITY;;Feb 14, 2008
;;Copyright 2000-2011, Medsphere Systems Corporation
;=================================================================
; RPC: CIAZG USER
; Returns info about user as IEN^Name
USERGET(DATA) ;
S DATA=DUZ_U_$$GET1^DIQ(200,DUZ,.01)_U_$$HASKEY^BEHOUSCX("CIAZGRU")
Q
; RPC: CIAZG DEFINITION DELETE
; Deletes a definition and its associated items and subdefinitions.
DEFNDEL(DATA,DEFN) ;
S DATA=$$DEFNDEL^CIAZGUTL(DEFN)
Q
; RPC: CIAZG DEFINITION CLONE
; Clones a definition
DEFNCLN(DATA,DEFN) ;
S DEFN=$$DEFNCLN^CIAZGUTL(DEFN)
I DEFN S DATA=0_U_DEFN
E S DATA="-1^Failed to clone the specified entry."
Q
; RPC: CIAZG DEFINITION CHILD
; Create a new child definition
DEFNSUB(DATA,DEFN,FLD,SOURCE) ;
S DATA=$$DEFNSUB^CIAZGUTL(DEFN,FLD,SOURCE)
Q
; RPC: CIAZG DEFINITION CLEANUP
; Cleanup orphaned child definitions
DEFNCLP(DATA) ;
D DEFNDLO^CIAZGUTL
S DATA=1
Q
; RPC: CIAZG DEFINITION CRITERIA
; Get criteria for definition
DEFNCRT(DATA,DEFN) ;
N ARY,CNT,VTP,X
D GETITEMS^CIAZGRU(DEFN,20,.ARY)
S (CNT,ARY)=0
F S ARY=$O(ARY(ARY)) Q:'ARY D
.S X=ARY(ARY,0),VTP=+$P($G(^CIAZG(19950.44,+$P(X,U,5),0)),U,2)
.Q:'VTP!'$P(X,U,6)
.S $P(ARY(ARY),U,4)=VTP
.D ADDCRT(ARY(ARY)),ADDCRT(ARY(ARY,-1)),ADDCRT(ARY(ARY,0))
.D ADDCRTW(10),ADDCRTW(20)
Q
ADDCRTW(MLT) ;
N X,Y
S X=+$P($G(ARY(ARY,MLT,0)),U,4)
D ADDCRT(X)
F Y=1:1:X D ADDCRT(ARY(ARY,MLT,Y,0))
Q
ADDCRT(VAL) ;
S CNT=CNT+1,DATA(CNT)=VAL
Q
Q
; RPC: CIAZG QUERY FETCH
; Fetch query result in XML format
; DATA: Global to receive data
; RSLT: Query result IEN
; STRT: Last record retrieved
; COUNT: # of record to retrieve (-1=all,0=none,>0=#)
; META: If nonzero, include metadata
RSLTGET(DATA,RSLT,STRT,COUNT,META) ;
D RSLTGET^CIAZGUTL(.DATA,.RSLT,.STRT,.COUNT,.META)
Q
; RPC: CIAZG QUERY ABORT
; Abort a query
RSLTABR(DATA,RSLT) ;
S DATA=$$RSLTABR^CIAZGUTL(RSLT)
Q
; RPC: CIAZG ITEMS CLEANUP
ITEMSCLP(DATA,ITEMS) ;
D ITEMDLO^CIAZGUTL(.ITEMS)
S DATA=1
Q
; RPC: CIAZG QUERY RUN
; Run the specified query
; DEFN: IEN of query definition
; VALS: Value list for user-supplied criteria
; WHEN: Optional date/time to run
; COHORT: Optional selection cohort
QRYRUN(DATA,DEFN,VALS,WHEN,COHORT) ;
N CRT,GBL
D GETCRT^CIAZGRU(DEFN,.CRT,.VALS)
S:$G(COHORT) GBL=$NA(^XTMP("CIAZGRU",COHORT,"IEN"))
S DATA=$$SUBMIT^CIAZGRU(DEFN,.WHEN,.CRT,.GBL)
Q
; RPC: CIAZG QUERY RERUN
; Rerun a query
; RSLT: IEN of query result
; WHEN: Optional date/time to run
QRYAGN(DATA,RSLT,WHEN,COHORT) ;
N CRT,PRT,SRT,DEFN,GBL,X
S DATA=0
Q:'$D(^XTMP("CIAZGRU",RSLT,0))
S DEFN=$P(^(0),U,3)
Q:'$D(^CIAZG(19950.41,DEFN,0))
F X="CRT","SRT","PRT" M @X=^XTMP("CIAZGRU",RSLT,X)
S:$G(COHORT) GBL=$NA(^XTMP("CIAZGRU",COHORT,"IEN"))
S DATA=$$SUBMIT2^CIAZGRU(DEFN,.WHEN,.CRT,.SRT,.PRT,.GBL)
Q
; RPC: CIAZG JOIN FIELDS
; Return a list of fields that point from one file (FROM)
; to a second file (TO) and that have a standard xref.
; Returns list in the format:
; <field #>^<field name>^<xref>
FLDJOIN(DATA,TO,FROM) ;
D FLDJOIN^CIAZGUTL(.TO,.FROM,.DATA)
Q
CIAZGRPC ;MSC/IND/DKM - Generic Retrieval RPC's;09-Dec-2011 10:12;PLS
+1 ;;1.4;GENERIC RETRIEVAL UTILITY;;Feb 14, 2008
+2 ;;Copyright 2000-2011, Medsphere Systems Corporation
+3 ;=================================================================
+4 ; RPC: CIAZG USER
+5 ; Returns info about user as IEN^Name
USERGET(DATA) ;
+1 SET DATA=DUZ_U_$$GET1^DIQ(200,DUZ,.01)_U_$$HASKEY^BEHOUSCX("CIAZGRU")
+2 QUIT
+3 ; RPC: CIAZG DEFINITION DELETE
+4 ; Deletes a definition and its associated items and subdefinitions.
DEFNDEL(DATA,DEFN) ;
+1 SET DATA=$$DEFNDEL^CIAZGUTL(DEFN)
+2 QUIT
+3 ; RPC: CIAZG DEFINITION CLONE
+4 ; Clones a definition
DEFNCLN(DATA,DEFN) ;
+1 SET DEFN=$$DEFNCLN^CIAZGUTL(DEFN)
+2 IF DEFN
SET DATA=0_U_DEFN
+3 IF '$TEST
SET DATA="-1^Failed to clone the specified entry."
+4 QUIT
+5 ; RPC: CIAZG DEFINITION CHILD
+6 ; Create a new child definition
DEFNSUB(DATA,DEFN,FLD,SOURCE) ;
+1 SET DATA=$$DEFNSUB^CIAZGUTL(DEFN,FLD,SOURCE)
+2 QUIT
+3 ; RPC: CIAZG DEFINITION CLEANUP
+4 ; Cleanup orphaned child definitions
DEFNCLP(DATA) ;
+1 DO DEFNDLO^CIAZGUTL
+2 SET DATA=1
+3 QUIT
+4 ; RPC: CIAZG DEFINITION CRITERIA
+5 ; Get criteria for definition
DEFNCRT(DATA,DEFN) ;
+1 NEW ARY,CNT,VTP,X
+2 DO GETITEMS^CIAZGRU(DEFN,20,.ARY)
+3 SET (CNT,ARY)=0
+4 FOR
SET ARY=$ORDER(ARY(ARY))
IF 'ARY
QUIT
Begin DoDot:1
+5 SET X=ARY(ARY,0)
SET VTP=+$PIECE($GET(^CIAZG(19950.44,+$PIECE(X,U,5),0)),U,2)
+6 IF 'VTP!'$PIECE(X,U,6)
QUIT
+7 SET $PIECE(ARY(ARY),U,4)=VTP
+8 DO ADDCRT(ARY(ARY))
DO ADDCRT(ARY(ARY,-1))
DO ADDCRT(ARY(ARY,0))
+9 DO ADDCRTW(10)
DO ADDCRTW(20)
End DoDot:1
+10 QUIT
ADDCRTW(MLT) ;
+1 NEW X,Y
+2 SET X=+$PIECE($GET(ARY(ARY,MLT,0)),U,4)
+3 DO ADDCRT(X)
+4 FOR Y=1:1:X
DO ADDCRT(ARY(ARY,MLT,Y,0))
+5 QUIT
ADDCRT(VAL) ;
+1 SET CNT=CNT+1
SET DATA(CNT)=VAL
+2 QUIT
+3 QUIT
+4 ; RPC: CIAZG QUERY FETCH
+5 ; Fetch query result in XML format
+6 ; DATA: Global to receive data
+7 ; RSLT: Query result IEN
+8 ; STRT: Last record retrieved
+9 ; COUNT: # of record to retrieve (-1=all,0=none,>0=#)
+10 ; META: If nonzero, include metadata
RSLTGET(DATA,RSLT,STRT,COUNT,META) ;
+1 DO RSLTGET^CIAZGUTL(.DATA,.RSLT,.STRT,.COUNT,.META)
+2 QUIT
+3 ; RPC: CIAZG QUERY ABORT
+4 ; Abort a query
RSLTABR(DATA,RSLT) ;
+1 SET DATA=$$RSLTABR^CIAZGUTL(RSLT)
+2 QUIT
+3 ; RPC: CIAZG ITEMS CLEANUP
ITEMSCLP(DATA,ITEMS) ;
+1 DO ITEMDLO^CIAZGUTL(.ITEMS)
+2 SET DATA=1
+3 QUIT
+4 ; RPC: CIAZG QUERY RUN
+5 ; Run the specified query
+6 ; DEFN: IEN of query definition
+7 ; VALS: Value list for user-supplied criteria
+8 ; WHEN: Optional date/time to run
+9 ; COHORT: Optional selection cohort
QRYRUN(DATA,DEFN,VALS,WHEN,COHORT) ;
+1 NEW CRT,GBL
+2 DO GETCRT^CIAZGRU(DEFN,.CRT,.VALS)
+3 IF $GET(COHORT)
SET GBL=$NAME(^XTMP("CIAZGRU",COHORT,"IEN"))
+4 SET DATA=$$SUBMIT^CIAZGRU(DEFN,.WHEN,.CRT,.GBL)
+5 QUIT
+6 ; RPC: CIAZG QUERY RERUN
+7 ; Rerun a query
+8 ; RSLT: IEN of query result
+9 ; WHEN: Optional date/time to run
QRYAGN(DATA,RSLT,WHEN,COHORT) ;
+1 NEW CRT,PRT,SRT,DEFN,GBL,X
+2 SET DATA=0
+3 IF '$DATA(^XTMP("CIAZGRU",RSLT,0))
QUIT
+4 SET DEFN=$PIECE(^(0),U,3)
+5 IF '$DATA(^CIAZG(19950.41,DEFN,0))
QUIT
+6 FOR X="CRT","SRT","PRT"
MERGE @X=^XTMP("CIAZGRU",RSLT,X)
+7 IF $GET(COHORT)
SET GBL=$NAME(^XTMP("CIAZGRU",COHORT,"IEN"))
+8 SET DATA=$$SUBMIT2^CIAZGRU(DEFN,.WHEN,.CRT,.SRT,.PRT,.GBL)
+9 QUIT
+10 ; RPC: CIAZG JOIN FIELDS
+11 ; Return a list of fields that point from one file (FROM)
+12 ; to a second file (TO) and that have a standard xref.
+13 ; Returns list in the format:
+14 ; <field #>^<field name>^<xref>
FLDJOIN(DATA,TO,FROM) ;
+1 DO FLDJOIN^CIAZGUTL(.TO,.FROM,.DATA)
+2 QUIT