source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/m/BMXADOVJ.m@ 1716

Last change on this file since 1716 was 1209, checked in by Sam Habiel, 13 years ago

BMXMON fix; updated all routines to v 2.31

File size: 3.5 KB
RevLine 
[645]1BMXADOVJ ; IHS/CIHA/GIS - RPC CALL: GENERATE DATA FOR AN ADO DATASET ;
[1209]2 ;;2.31;BMX;;Jul 25, 2011
[645]3 ; THIS ROUTINE MANAGES THE JOINS
4 ;
5 ;
6 ;
7 ; THE FIFTH PARAMETER OF SS^BMXADO CONTAINS THE JOIN INSTRUCTIONS
8 ; SYNTAX: DESCENDANT SCHEMA IEN (DETAILS FILE), JOIN FIELD FROM MASTER FILE
9 ; THE FIRST "," PIECE STATES THAT THE MASTER FILE IS JOINED BY ITS .02 FIELD TO THE DETAILS FILE
10 ; THE SECOND "," PIECE STARTES THAT THE DETAILS FILE IS DEFINED BY SCHEMA #6
11 ; AN OPTIONAL 3RD "," PIECE MAY CONTAIN A SECONDARY VSTG TO MORE PRECISELY DEFINE JOIN ITERATION
12 ; E.G., "...~6.,.02,AA~1/1/2004~2/1/2004~~~~~|WT|R"
13 ; IN THIS CASE, THE SECONDARY VSTG SPECIFIES THAT THE AA INDEX BE USED TO CONTROL THE ITERATOR
14 ; THE START AND STOP DATES ARE IN EFFECT BUT MAX IS IGNORED/IRRELEVANT
15 ; THE 1ST "|" PIECE OF THE PARAM SECTION WILL BE AUTOMATICALLY STUFFED WITH PATEINT DFN(S) DURING ITERATION
16 ; IF MULTIPLE JOINS ARE REQUESTED, THEY ARE SPARATED BY THE '@JOIN@' DELIMTER
17 ; "E.G., 6,.02@JOIN@1,.03@JOIN@2,.02@JOIN@9,SUB"
18 ; IN THIS EXAPLE THE MASTER FILE IS JOIND TO THE DETAILS FILES ASSOCIATED WITH SCHEMAS 6, 1, AND 9
19 ; NOTE THAT THE 3RD JOIN DEINED IN THE STRING SPECIFIES A SUBFILE REALTION RATHER THAN A "POINTER" RELATION
20 ; IF A SECOND RECORD SET IS CREATED TO FULFILL A JOIN REQUEST, IT WILL ONLY CONTAIN THE ROWS NECESSARY TO COMPLETE THE JOIN
21 ;
22JOIN(SMASTER,JSTG) ;EP - APPEND ADDITIONAL ANRS TO FULFILL JOIN REQUESTS
23 N TMP,JOIN,JINST,FMASTER
24 I '$L($G(JSTG)) Q ; JOIN STRING MUST NOT BE NULL
25 S FMASTER=$P($G(^BMXADO(+$G(SMASTER),0)),U,2) I 'FMASTER Q ; MASTER SCHEMA & FILE MUST EXIST
26 S TMP=$NA(^TMP("BMX JOIN",$J)) K @TMP ; JOIN INFO TEMP STORAGE ARRAY
27 S @TMP@(0,SMASTER)=$$RANGE ; GET DATA NODE RANGE FOR THE MASTER ANR
28 I '$D(@TMP@(0)) Q ; DATA MUST EXIST IN THE MASTER FILE OR QUIT
29 F JOIN=1:1 S JINST=$P(JSTG,"@JOIN@",JOIN) Q:JINST="" D J(SMASTER,JINST) ; MAIN LOOP FOR DOING JOINS
30 K @TMP
31 Q
32 ;
33RANGE() ; GET DATA NODE RANGE FOR LAST SCHEMA ENTERED
34 N X,FIRST,LAST,Y
35 S (X,LAST)=$O(@OUT@(999999999),-1)
36 F S X=$O(@OUT@(X),-1) Q:'X S Y=@OUT@(X) Q:Y'[$C(30) S FIRST=X
37 I '$G(FIRST) Q ""
38 S FIRST=FIRST+1
39 Q (FIRST_U_LAST)
40 ;
41J(SMASTER,JSTG) ; JOIN DETAILS FILE TO MASTER FILE
42 ; SMASTER=MASTER SCHMA IEN, SDETAIL=DETAILS SCHEMA IEN
43 N JARR,SEC,ERR,JIEN,SUB,IX,PARENT,JFLD,DFLD,NODE,X,STOP,VSTG2,SDETAIL,JFLD
44 S SDETAIL=$P(JSTG,C),JFLD=$P(JSTG,C,2),DFLD=$P(JSTG,C,3),VSTG2=$P(JSTG,C,4,999)
45 I JFLD="SUB" S JFLD=.001,DFLD=.0001
46 I JFLD=.001,DFLD=.0001 S SUB=1,VSTG2="~~~~~SIT~BMXADOVJ~" ; MAKE SUBFILE ITERATOR VSTG
47 D IEN(SMASTER,SDETAIL,JFLD) ; GET A LIST OF JOIN IENS FROM THE MASTER FILE
48 I '$D(@TMP@(1)) Q ; NO MASTER FILE IENS FOR JOINS, SO QUIT
49 N FIEN,DAS,SIEN,VSTG,JSTG
50 S DAS="",SIEN=SDETAIL,VSTG=VSTG2
51 S FIEN=$P($G(^BMXADO(SIEN,0)),U,2) I 'FIEN Q
52 D JEP^BMXADO ; BUILD THE JOIN ANR
53 Q
54 ;
55IEN(SMASTER,SDETAIL,JFLD) ; GET THE MASTER FILE IENS FOR BUILDING THE JOIN DATA SET
56 N FIEN,%,FIRST,LAST,NODE,DA,IEN
57 I JFLD["IEN" S JFLD=+JFLD
58 S FIEN=$P($G(^BMXADO(SMASTER,0)),U,2) I 'FIEN Q
59 S %=$G(@TMP@(0,SMASTER)) I '$L(%) Q
60 S FIRST=+%,LAST=$P(%,U,2),NODE=FIRST-.1
61 F S NODE=$O(@OUT@(NODE)) Q:'NODE Q:NODE>LAST D
62 . S DA=+@OUT@(NODE)
63 . I 'DA Q
64 . I JFLD=.001 S @TMP@(1,SDETAIL,DA)="" Q
65 . S IEN=$$GET1^DIQ(FIEN,(DA_C),JFLD,"I") I 'IEN Q
66 . S @TMP@(1,SDETAIL,IEN)=""
67 . Q
68 Q
69 ;
70JFLD ; EP-STUFF JOIN FIELD IDS INTO THE INTRO SEGMENT OF THE SCHEMA
71 N NODE,%
72 S NODE=999999999999
73 F S NODE=$O(@OUT@(NODE),-1) Q:'NODE I ^(NODE)["@@@meta@@@" Q
74 I 'NODE Q
75 S %=$P(@OUT@(NODE),U),$P(%,"|",4)=$G(JFLD),$P(%,"|",5)=$G(DFLD)
76 S @OUT@(NODE)=%_U
77 Q
78 ;
Note: See TracBrowser for help on using the repository browser.