Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SCMCDDR

SCMCDDR.m

Go to the documentation of this file.
SCMCDDR ;ALB/ART - FileMan LIST^DIC DBS Call for PCMM Web RPCs ;02/26/2015
 ;;5.3;Scheduling;**603**;Aug 13, 1993;Build 79
 ;
 ;This routine was copied from DDR.  PCMM/R needs a new RPC that has .11 APP PROXY ALLOWED set to Yes
 ;
 ;Public, Supported ICRs
 ; #2051 - Database Server API: Lookup Utilities (DIC)
 ; #2238 - CHANGE RPC RETURN TYPE (XWBLIB)
 ; #2239 - XWBAPVER -- RPC VERSION
 ;
 ;DDR ;ALB/MJK,SF/DCM-FileMan Delphi Components' RPCs ;4/28/98  10:38
 ;;22.0;VA FileMan;;Mar 30, 1999
 ;Per VHA Directive 10-93-142, this routine should not be modified.
 ;
 QUIT
 ;
LISTC(SCDATA,SC) ; -- broker callback to get list data
 N SCFILE,SCIENS,SCFLDS,SCMAX,SCFROM,SCPART,SCXREF,SCSCRN,SCID,SCVAL,SCERR,SCRSLT,SCFLD,SCFLAGS,SCOPT,SCOUT,DIERR
 ; -- parse array to parameters
 D PARSE(.SC)
 S SCPART=$TR(SCPART,$C(13)_$C(10),"")
 ; -- get specific field criteria
 IF $G(SC("DDFILE")),$G(SC("DDFIELD")),$D(^DD(SC("DDFILE"),SC("DDFIELD"),12.1)) D
 . N DIC X ^(12.1) S:$D(DIC("S")) SCSCRN=DIC("S")
 I 'XWBAPVER D V0 Q
 I XWBAPVER>0 D V1 Q
 Q
 ;
DIC ;
 D LIST^DIC(SCFILE,SCIENS,SCFLDS,SCFLAGS,SCMAX,.SCFROM,SCPART,SCXREF,SCSCRN,SCID,SCOUT,"SCERR")
 Q
 ;
V0 ;
 S SCOUT="SCRSLT",SCFLAGS=$G(SCFLAGS)_"P",SCFLDS=$G(SCFLDS)_";@"
 D DIC
 N Y,I,N S N=0
 I $G(SCFROM)]"" D SET("[Misc]"),SET("MORE"_U_SCFROM_U_SCFROM("IEN"))
 I $D(SCRSLT("DILIST")) D
 . D SET("[Data]")
 . S I=0 F  S I=$O(SCRSLT("DILIST",I)) Q:'I  D SET(SCRSLT("DILIST",I,0))
 IF $D(SCERR) D SET("[Errors]")
 S X=$$STYPE("ARRAY")
 Q
 ;
STYPE(X,WRAP) ;For backward compatability only
 I $D(WRAP) Q $$RTRNFMT^XWBLIB($G(X),WRAP)
 Q $$RTRNFMT^XWBLIB(X)
 ;
V1 ;
 S SCOUT=""
 I XWBAPVER=1,SCFLAGS["P" S SCFLAGS=SCFLAGS_"S" ;only P flag is sent from client for V1 of FMCD
 D DIC
 I $G(SCFLAGS)["P" D  Q
 . I $D(^TMP("DILIST",$J)) D
 . . N END S END=+^TMP("DILIST",$J,0)
 . . I XWBAPVER>1 S ^(.3)="[MAP]",^TMP("DILIST",$J,.4)=^TMP("DILIST",$J,0,"MAP")
 . . K ^TMP("DILIST",$J,0) S ^(.5)="[BEGIN_diDATA]",^(END+1)="[END_diDATA]"
 . D 11,31
 . S SCDATA=$NA(^TMP("DILIST",$J))
 . Q
 I $G(SCFLAGS)'["P" D 11,UNPACKED,31 S SCDATA=$NA(^TMP("DILIST",$J)) Q
 Q
11 ;
 I $G(SCFROM)]"" S ^TMP("DILIST",$J,.1)="[Misc]",^(.2)="MORE"_U_SCFROM_U_SCFROM("IEN")_$S(XWBAPVER>1:U_$P($G(^TMP("DILIST",$J,0)),U,4),1:"")
 Q
31 ;
 I $D(DIERR) D ERROR
 Q
SET(X) ;
 S N=N+1
 S SCDATA(N)=X
 Q
PARSE(SC) ; -- array parsing
 S SCFILE=$G(SC("FILE"))
 S SCIENS=$G(SC("IENS"))
 S SCFLDS=$G(SC("FIELDS"))
 S SCFLAGS=$G(SC("FLAGS"))
 S SCMAX=$G(SC("MAX"),"*")
 M SCFROM=SC("FROM")
 S SCPART=$G(SC("PART"))
 S SCXREF=$G(SC("XREF"))
 S SCSCRN=$G(SC("SCREEN"))
 S SCID=$G(SC("ID"))
 S SCOPT=$G(SC("OPTIONS"))
 Q
ERROR ;
 N I S I=1
 D Z("[BEGIN_diERRORS]")
 N A S A=0 F  S A=$O(SCERR("DIERR",A)) Q:'A  D
 . N HD,PARAM,B,C,TEXT,TXTCNT,D,FILE,FIELD,IENS,%
 . S HD=SCERR("DIERR",A)
 . I $D(SCERR("DIERR",A,"PARAM",0)) D
 . . S (B,D)=0 F C=1:1 S B=$O(SCERR("DIERR",A,"PARAM",B)) Q:B=""  D
 . . . I B="FILE" S FILE=SCERR("DIERR",A,"PARAM","FILE")
 . . . I B="FIELD" S FIELD=SCERR("DIERR",A,"PARAM","FIELD")
 . . . I B="IENS" S IENS=SCERR("DIERR",A,"PARAM","IENS")
 . . . S D=D+1,PARAM(D)=B_U_SCERR("DIERR",A,"PARAM",B)
 . S C=0 F  S C=$O(SCERR("DIERR",A,"TEXT",C)) Q:'C  S TEXT(C)=SCERR("DIERR",A,"TEXT",C),TXTCNT=C
 . S HD=HD_U_TXTCNT_U_$G(FILE)_U_$G(IENS)_U_$G(FIELD)_U_$G(D) D Z(HD)
 . S B=0 F  S B=$O(PARAM(B)) Q:'B  S %=PARAM(B) D Z(%)
 . S B=0 F  S B=$O(TEXT(B)) Q:'B  S %=TEXT(B) D Z(%)
 . Q
 D Z("[END_diERRORS]")
 Q
Z(%) ;
 S ^TMP("DILIST",$J,"ZERR",I)=%,I=I+1
 Q
 ;
UNPACKED ;
 Q:'$D(^TMP("DILIST",$J))
 N COUNT,IXCNT
 S COUNT=+^TMP("DILIST",$J,0) Q:'COUNT
 I XWBAPVER>1 S ^TMP("DILIST",$J,.3)="[MAP]",^TMP("DILIST",$J,.4)=^TMP("DILIST",$J,0,"MAP")
 K ^TMP("DILIST",$J,0)
 S ^TMP("DILIST",$J,.5)="[BEGIN_diDATA]"
 I XWBAPVER=1 D IX1
 D IENS,FLDS,WID,END
 Q
IX1 ;
 I SCOPT["IX",$D(^TMP("DILIST",$J,1)) D
 . S ^TMP("DILIST",$J,1,COUNT+1)="END_IXVALUES" D  S ^(.1)="BEGIN_IXVALUES",^(.2)=IXCNT
 . . N Z S Z=0,IXCNT=0 I $G(^TMP("DILIST",$J,1,1))]"" S IXCNT=1 Q
 . . F  S Z=$O(^TMP("DILIST",$J,1,1,Z)) Q:'Z  S IXCNT=IXCNT+1
 I SCOPT'["IX" K ^TMP("DILIST",$J,1)
 Q
IENS ;
 I $D(^TMP("DILIST",$J,2)) D
 .  S ^TMP("DILIST",$J,2,.1)="BEGIN_IENs",^(COUNT+1)="END_IENs"
 Q
FLDS ;
 I SCFLDS]"",$D(^TMP("DILIST",$J,"ID")) D
 . N Z,FLD,FLDCNT S FLD="",(Z,FLDCNT,I)=0
 . ;I XWBAPVER>1,SCFLDS["IX" D
 . ;. F  S I=$O(^TMP("DILIST",$J,"ID",1,0,I)) Q:'I  S IXCNT=IXCNT+1
 . ;. S ^TMP("DILIST",$J,"ID",0,0)="IXCNT="_IXCNT Q
 . F  S Z=$O(^TMP("DILIST",$J,"ID",1,Z)) Q:'Z   S FLD=FLD_Z_";",FLDCNT=FLDCNT+1
 . Q:'FLDCNT
 . S ^TMP("DILIST",$J,"ID",0)="BEGIN_IDVALUES"
 . I XWBAPVER=1 S ^TMP("DILIST",$J,"ID",.1)=FLD_U_FLDCNT
 . S ^TMP("DILIST",$J,"ID",COUNT+1)="END_IDVALUES"
 E  D
 . N Z S Z=0 F  S Z=$O(^TMP("DILIST",$J,"ID",Z)) Q:'Z  K ^TMP("DILIST",$J,"ID",Z)
 Q
WID ;
 I (SCOPT["WID")!(SCFLDS["WID"),$D(^TMP("DILIST",$J,"ID","WRITE")) D
 . N Z,N,I,IEN,WIDCNT S (N,I)=0
 . M Z=^TMP("DILIST",$J,"ID","WRITE") K ^TMP("DILIST",$J,"ID","WRITE")
 . S ^TMP("DILIST",$J,"ID","WID",0)="BEGIN_WIDVALUES",N=N+1
 . F  S I=$O(Z(I)) Q:'I  S IEN=$G(^TMP("DILIST",$J,2,I)) D
 . . N J S (J,WIDCNT)=0 F  S J=$O(Z(I,J)) Q:'J  S WIDCNT=WIDCNT+1
 . . S ^TMP("DILIST",$J,"ID","WID",N)="WID"_U_IEN_U_WIDCNT,N=N+1
 . . N J S J=0 F J=1:1:WIDCNT S ^TMP("DILIST",$J,"ID","WID",N)=Z(I,J),N=N+1
 . S ^TMP("DILIST",$J,"ID","WID",N)="END_WIDVALUES"
 I (SCOPT'["WID")&(SCFLDS'["WID") K ^TMP("DILIST",$J,"ID","WRITE")
 Q
END ;
 S ^TMP("DILIST",$J,"IDZ")="[END_diDATA]"
 Q