BMXADOX1 ; IHS/CIHA/GIS - RPC CALL: GENERATE AN ADO SCHEMA STRING AND DATA SET ;
;;2.0;BMX;;FEB 26, 2007
; EXMAPLES OF FILEMAN SCHEMA GENERATION
;
;
; N OUT,DAX,% S DAX=0 D SS^BMXADO(.OUT,1,DAX,"^^^5^I^^^^3,XSUB,2160010.03") D DISP(OUT) Q ; TEST EXTENDED SUBJOIN
;
DISP(OUT) ;
D DISP^BMXADOX(OUT)
Q
;
SCHEMA(NAME) ; GIVEN SCHEMA NAME, RETURN THE IEN
N IEN
S IEN=$O(^BMXADO("B",NAME,0))
Q IEN
;
NUM ; ITERATE BY IEN
; IX="",START WITH IEN=1, STOP AFTER IEN=20, MAX # RECORDS RETURNED = 5
; TO VIEW INTERNAL VALUES SET VSTG="~1~20~5~I"
N OUT,%,SIEN
S SIEN=$$SCHEMA("IHS PATIENT")
D SS^BMXADO(.OUT,SIEN,"","~1~20~5")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
IX ; ITERATE BY INDEX
; ITERATE USING THE "B" INDEX
; START WITH PT NAME "C", STOP AFTER PATIENT NAME = "D", MAX # RECORDS RETURNED = 5
N OUT,%,SIEN
S SIEN=$$SCHEMA("IHS PATIENT")
D SS^BMXADO(.OUT,SIEN,"","B~C~D~5")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
VCN ; SHOW VALUES FOR A SINGLE VISIT THAT AS A DEFINED VCN
N OUT,%,SIEN
S SIEN=$$SCHEMA("BMXADO DATA ENTRY IDENTIFIERS")
D SS^BMXADO(.OUT,SIEN,"","VCN~1.242A~1.242A~")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
MT ; MEASUREMNT TYPES
N OUT,%,SIEN
S SIEN=$$SCHEMA("BMXADO MEASUREMENT TYPES")
D SS^BMXADO(.OUT,SIEN,"","B~~")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
PROB ; PATIENT PROBLEMS
N OUT,%,SIEN
S SIEN=$$SCHEMA("BMXADO PROBLEMS")
D SS^BMXADO(.OUT,SIEN,"","AA~53~53")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
PB1 ; ALT PROB RETRIEVAL TEST
N OUT,%,SIEN
S SIEN=$$SCHEMA("BMXADO PROBLEMS")
D SS^BMXADO(.OUT,SIEN,"","~221~221~")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
POV ; RETURN THE POV SCHEMA
N OUT,%,SIEN
S SIEN=$$SCHEMA("BMXADO ADD POV")
D SS^BMXADO(.OUT,SIEN,"","")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
NOTES ; RETURN NOTES FOR A SPECIFIC PATIENT PROBLEMS
N OUT,%,SIEN
S SIEN=$$SCHEMA("BMXADO NOTES")
D SS^BMXADO(.OUT,SIEN,"","~~~~~NOTES~BMXADOFD~53")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
RENT ; ITERATE IN CHUNKS
; RE-ITERATE USING THE "B" INDEX
; START WITH PT IEN 5 AS THE "SEED", STOP AFTER PATIENT NAME = "D", MAX # RECORDS RETURNED = 5
N OUT,%,SIEN,SEED,LSEED,X,Y
S SEED=0,LSEED=""
S SIEN=$$SCHEMA("IHS PATIENT")
RIT F D I '$G(SEED) Q
. ; D SS^BMXADO(.OUT,SIEN,SEED,"B~CA~CB~5")
. D SS^BMXADO(.OUT,SIEN,SEED,"~~~5")
. D DISP(OUT) R %:$G(DTIME,60) E S SEED="" Q
. I %?1"^" S SEED="" Q
. S X=$P(@OUT@(1),U,1)
. S SEED=$P(X,"|",3)
. I SEED=LSEED S SEED="" Q
. S LSEED=SEED
. K ^TMP("BMX ADO",$J)
. Q
Q
;
SUB ; SUBFILE ITERATION
; THE SCHEMA IS ATTACHED TO THE MEDICARE ELIGIBILITY FILE/ELIG DATE SUBFILE
; THE DA STRING HAS A VALUE OF '1,',: THE IEN IN THE PARENT FILE.
; NOTE THE COMMA IN THE DA STRING. THIS INDICATES THAT THE FILE IEN IS 1 BUT THE SUBFILE IEN IS UNSPECIFIED
N OUT,%,SIEN
S SIEN=$$SCHEMA("UPDATE MEDICARE DATES")
D SS^BMXADO(.OUT,SIEN,"1,","~~~")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
DINUM ; DINUMED POINTER ITERATION
; THE SCHEMA IS ATTACHED TO THE IHS PATIENT FILE (9000001)
; THE IHS PATIENT FILE IS DINUM'D AND ITS .01 FIELD POINTS TO THE VA PATIENT FILE (2)
; BECAUSE OF THE SPECIAL RELATIONSHIP BETWEEN THE FILES, WE CAN USE THE B INDEX OF FILE 2 TO ITERATE FILE 9000001.
N OUT,%,SIEN
S SIEN=$$SCHEMA("IHS PATIENT")
D SS^BMXADO(.OUT,SIEN,"","B~A~B~5")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
IXP ; INDEXED POINTER ITERATION
; THE SCHEMA IS ATTACHED TO THE V POV FILE
; THE AC CROSS REFERENCE INDEXES THE PATIENT FIELD
; BY STARTING AND STOPING WITH PATIENT 1 (MAX=5) WE COLLECT THE FIRST 5 POVS FOR PATIENT 1 IN THE FILE
N OUT,%,SIEN
S SIEN=$$SCHEMA("VIEW POVS")
D SS^BMXADO(.OUT,SIEN,"","AC~1~1~5")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
AA ; ITERATE USING AA INDEX
; INDEX IS 'AA" THE START AND STOP DATES ARE SPECIFIED IN EXTERNAL FORMAT. MAX=10
; THE FOLLOWING FILTERS ARE SPECIFIED IN THE LAST PARAMETER ("1|WT|C"):
; 1=PATIENT DFN #1
; WT=RETURN ONLY WEIGHTS. MEASUREMENT TYPE MUST BE SPECIFIED WITH A VALID, UNAMBIGUOUS LOOKUP VALUE.
; C=RETRUN VALUES IN CHRONOLOGICAL ORDER USE 'R' INSTEAD OF 'C' FOR REVERSE CHRONOLOGICAL ORDER. DEFAULT=C
; THE SEED PARAMTER IS SET AND CAN BE USED TO RETURN DATA IN CHUNKS
N OUT,%,SIEN
S SIEN=$$SCHEMA("VIEW MEASUREMENTS")
D SS^BMXADO(.OUT,SIEN,"","AA~3/21/1985~6/4/1986~5~~~~1|WT|C")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
AA2 ; ITERATE USING AA INDEX
; THIS SCHEMA IS ATTACHED TO THE VISIT FILE (9000010)
; IN THIS CASE THERE IS NO ATTRIBUTE TYPE SO THE FILTER PARAM HAS ONLY 2 PIECES "1|R"
; 1=PATIENT DFN
; R=RETURN DATA IN REVERSE CHRONOLOGICAL ORDER
N OUT,%,SIEN
S SIEN=$$SCHEMA("VISITS")
D SS^BMXADO(.OUT,SIEN,"","AA~3/21/1985~6/4/1986~5~~~~1|R")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
CIT ; CUSTOM ITERATOR
; IF COMPLEX OR UNUSUAL SORTING/FILTERING IS REQUITED, USE A CUSTOM ITERATOR
; THE CUSTOM ITERATOR IS DEFINED BY 6TH, 7TH AND 8TH PIECES IN THE VSTG
; PIECE 8=TAG, PIECE 9=ROUTINE, PIECE 8=A PARAMETER PASSED TO THE ENTRY POINT
; THE 9TH PIECE CONTAINS PT DFN, TIMESTAMP, VISIT TYPE, LOC IEN, AND SERVICE CATEGORY IN A "|" DELIMTED STRING
; THE ITERATOR CALL TAG^ROUTINE(PARAM) TO GENERATE IENS
; IN THIS CASE THE SCHEMA IS ATTACHED TO THE VISIT FILE.
; GIVEN THE INFORMATION IN THE PARAMETER, THE CUSTOM ITERATOR RETURNS POSSIBLE DUPLICATE VISITS
N OUT,%,SIEN
S SIEN=$$SCHEMA("VISITS")
D SS^BMXADO(.OUT,SIEN,"","~~~~~DUPV~BMXADOV2~1|4/19/04@1PM|I|4585|A~")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
TRIGGER ; TEXT TRIGGER FUNCTION
N OUT,%,SIEN
S SIEN=$$SCHEMA("PATIENT DEMOGRAPHICS")
D SS^BMXADO(.OUT,SIEN,"","~1~5")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
ID ; IDENTIFIER FIELD
; THE SCHEMA IS ATTACHED TO THE VA PATIENT FILE (2)
; THE SCHEMA HAS A BUILT IN FIELD (.01ID) THAT RETURNS THE IDENTIFIERS
; THE ENTRY POINT THAT GENERATES THE IDETIFIERS IS STORED IN THE BMX ADO SCHEMA FILE
N OUT,%,SIEN
S SIEN=$$SCHEMA("UPDATE PATIENT DEMOGRAPHICS")
D SS^BMXADO(.OUT,SIEN,"","~1~1~")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
JMD ; JOIN MASTER TO DETAIL
N OUT,%,SIEN1,SIEN2,VSTG,SIEN3,JSTG
S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
S SIEN2=$$SCHEMA("VIEW MEASUREMENTS")
S SIEN3=$$SCHEMA("VIEW MEDS")
S VSTG="~1~5" ; INSTRUCTIONS FOR GATHERING DATA SET FOR PTS 1-5 FROM THE MASTER FILE
S JSTG=SIEN3_",.001,.02IEN,AA~1/1/1960~6/30/2004~~~~~|C" ; + INSTRUCTIONS FOR 1ST JOIN TO GET MEDS
S JSTG=JSTG_"@JOIN@"_SIEN2_",.001,.02IEN,AA~1/1/1988~12/31/1988~~~~~|WT|R" ; + INSTRUCTIONS FOR 2ND JOIN TO GET MSRMNTS
D SS^BMXADO(.OUT,SIEN1,"",VSTG,JSTG)
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
JVPT ; JOIN PT DEMOG TO VISIT
N OUT,%,SIEN1,SIEN2,VSTG,JSTG
S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
S SIEN2=$$SCHEMA("VISITS")
S VSTG="~1~1" ; INSTRUCTIONS FOR GATHERING DATA SET FOR PT 5 FROM THE MASTER FILE
S JSTG=SIEN2_",.05IEN,.001,AC" ; + INSTRUCTIONS FOR 1ST JOIN TO GET VISIT INFO
D SS^BMXADO(.OUT,SIEN1,"",VSTG,JSTG)
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
JAC ; TEST AC INDEX
N OUT,%,SIEN1,SIEN2
S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
S SIEN2=$$SCHEMA("VIEW LABS")
S SIEN3=$$SCHEMA("VIEW MEASUREMENTS")
D SS^BMXADO(.OUT,SIEN1,"","~3~5~~~~~~"_SIEN2_",.001,.02IEN,AC@JOIN@"_SIEN3_",.001,.02IEN,AC")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
JPB ; TEST AA INDEX JOINS FOR PROBLEM LIST
N OUT,%,SIEN1,SIEN2
S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
S SIEN2=$$SCHEMA("VIEW PROBLEMS")
D SS^BMXADO(.OUT,SIEN1,"","~1~5~~~~~~"_SIEN2_",.001,.02IEN,AA")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
JSUB ; SUBFILE JOIN
; IN THIS CASE THE RECORDS IN A PARENT FILE ARE "JOINED" TO THE RECORDS IN ONE OF ITS SUB FILES
; THE SCHEMA IS ATTACHED TO THE "MEDICARE ELIGIBLE" FILE
; IT IS JOINED TO ITS SUBFILE, "ELIG DATES", VIA THE UPDATE MEDICARE DATES SCHEMA
N OUT,%,SIEN1,SIEN2
S SIEN1=$$SCHEMA("UPDATE MEDICARE INFO")
S SIEN2=$$SCHEMA("UPDATE MEDICARE DATES")
D SS^BMXADO(.OUT,SIEN1,"","~1~5~~~~~~"_SIEN2_",SUB")
D DISP(OUT) R %:$G(DTIME,60)
K ^TMP("BMX ADO",$J)
Q
;
ADD ; ADD A NEW ENTRY
; THIS IS A 2 STEP PROCESS:
; FIRST GET THE SCHEMA FOR THE FILE YOU WISH TO UPDATE
; THIS SCHEMA TYPICALLY BEGINS WITH THE WORD "UPDATE"
; IT CONTAINS NO ID IR IEN FIELDS
; SECOND ADD THE DATA NODE TO THE ARRAY
; IT HAS THE SAME FORMAT AS A DATA STRING ASSOCIATED WITH THE SCHEMA EXCEPT THE FIRST "^" PIECE IS NULL
; THIS PIECE CORRESPONDS TO THE IEN OF THE RECORD. SINCE THE RECORD HASNOT BEEN ADDED YET, IT IS NULL.
; IN THE DATA STRING, ALL POINTER VALUES ARE PRECEDED BY THE '`' CHARACTER AND EA. STRING ENDS IN $C(30)
; MULTIPLE DATA STRINGS CAN BE APPENDED AS NEW NODES AT THE BOTTOM OF THE ARRAY
; IN THIS CASE WE ARE ADDING A RECORD TO THE V MEASUREMENT FILE
; DATA STRING="^MEASUREMENT TYPE IEN^PATIENT DFN^VISIT IEN^RESULT"_$C(30)
; THERE ARE 2 INPUT PARAMS:
; THE CLOSED REF WHERE THE INPUT ARRAY IS STORED
; SINCE IT IS PASSED BY REFERENCE "OUT" CAN BE NULL OR UNDEFIEND.
; OUT WILL BE DEFINED AT THE CONCLUSION OF THE TRANSACTION.
; THE OUTPUT IS IN THE OUT ARRAY
; OUT(1)="OK|ien" WHERE ien IS THE IEN OF THE RECORD THAT HAS BEE ADDED.
; IF THE TRANSACTION FAILED, AN ERROR MSG WILL BE IN THE OUT ARRAY
;
N OUT,%,SIEN,NODE
S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
S ^TMP("BMX ADO",$J,NODE)="^`2^`1^`71164^175.75"_$C(30)
D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
K ^TMP("BMX ADO",$J)
W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
Q
;
DELREC ; DELETE AN ENTRY
; THE SIMPLEST WAY TO DELETE AN ENTRY IS TO PUT THE RECORD IEN IN THE DA STRING PRECEDED BY A MINUS SIGN
; YOU CAN ALSO SET THE VALUE OF THE .01 FIELD TO "@"
; IF THE VALUE OF THE .01 FIELD IS NULL AND THE DA STRING IS NOT PRECEDED BY A MINUS SIGN, THE TRANSACTION WILL BE CANCELLED
; IF THE DA STRING IS NULL, THE TRANSACTION WILL BE CANCELLED
N OUT,%,SIEN,NODE,DEL
S DEL=51385
S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
S ^TMP("BMX ADO",$J,NODE)="-"_DEL_$C(30)
D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
K ^TMP("BMX ADO",$J)
W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
Q
;
EDIT ; EDIT AN EXISTING ENTRY
; SIMILAR TO ABOVE EXCEPT THAT THE FIRST "^" PIECE OF THE DATA NODE IS THE IEN OF THE RECORD TO BE EDITIED
; NOTE THAT THERE IS NO '`' IN FRONT OF THE FIRST PIECE. IT IS A PURE INTEGER
N OUT,%,SIEN,NODE
S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
S ^TMP("BMX ADO",$J,NODE)="51385^^^^176^`6"_$C(30)
D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
K ^TMP("BMX ADO",$J)
W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
Q
;
DELVAL ; DELETE A VALUE IN A FIELD
; SIMILAR TO EDIT EXCEPT THE VALUE IS "@"
N OUT,%,SIEN,NODE
S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
S ^TMP("BMX ADO",$J,NODE)="51385^^^^^@"_$C(30)
D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
K ^TMP("BMX ADO",$J)
W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
Q
BMXADOX1 ; IHS/CIHA/GIS - RPC CALL: GENERATE AN ADO SCHEMA STRING AND DATA SET ;
+1 ;;2.0;BMX;;FEB 26, 2007
+2 ; EXMAPLES OF FILEMAN SCHEMA GENERATION
+3 ;
+4 ;
+5 ; N OUT,DAX,% S DAX=0 D SS^BMXADO(.OUT,1,DAX,"^^^5^I^^^^3,XSUB,2160010.03") D DISP(OUT) Q ; TEST EXTENDED SUBJOIN
+6 ;
DISP(OUT) ;
+1 DO DISP^BMXADOX(OUT)
+2 QUIT
+3 ;
SCHEMA(NAME) ; GIVEN SCHEMA NAME, RETURN THE IEN
+1 NEW IEN
+2 SET IEN=$ORDER(^BMXADO("B",NAME,0))
+3 QUIT IEN
+4 ;
NUM ; ITERATE BY IEN
+1 ; IX="",START WITH IEN=1, STOP AFTER IEN=20, MAX # RECORDS RETURNED = 5
+2 ; TO VIEW INTERNAL VALUES SET VSTG="~1~20~5~I"
+3 NEW OUT,%,SIEN
+4 SET SIEN=$$SCHEMA("IHS PATIENT")
+5 DO SS^BMXADO(.OUT,SIEN,"","~1~20~5")
+6 DO DISP(OUT)
READ %:$GET(DTIME,60)
+7 KILL ^TMP("BMX ADO",$JOB)
+8 QUIT
+9 ;
IX ; ITERATE BY INDEX
+1 ; ITERATE USING THE "B" INDEX
+2 ; START WITH PT NAME "C", STOP AFTER PATIENT NAME = "D", MAX # RECORDS RETURNED = 5
+3 NEW OUT,%,SIEN
+4 SET SIEN=$$SCHEMA("IHS PATIENT")
+5 DO SS^BMXADO(.OUT,SIEN,"","B~C~D~5")
+6 DO DISP(OUT)
READ %:$GET(DTIME,60)
+7 KILL ^TMP("BMX ADO",$JOB)
+8 QUIT
+9 ;
VCN ; SHOW VALUES FOR A SINGLE VISIT THAT AS A DEFINED VCN
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("BMXADO DATA ENTRY IDENTIFIERS")
+3 DO SS^BMXADO(.OUT,SIEN,"","VCN~1.242A~1.242A~")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
MT ; MEASUREMNT TYPES
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("BMXADO MEASUREMENT TYPES")
+3 DO SS^BMXADO(.OUT,SIEN,"","B~~")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
PROB ; PATIENT PROBLEMS
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("BMXADO PROBLEMS")
+3 DO SS^BMXADO(.OUT,SIEN,"","AA~53~53")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
PB1 ; ALT PROB RETRIEVAL TEST
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("BMXADO PROBLEMS")
+3 DO SS^BMXADO(.OUT,SIEN,"","~221~221~")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
POV ; RETURN THE POV SCHEMA
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("BMXADO ADD POV")
+3 DO SS^BMXADO(.OUT,SIEN,"","")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
NOTES ; RETURN NOTES FOR A SPECIFIC PATIENT PROBLEMS
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("BMXADO NOTES")
+3 DO SS^BMXADO(.OUT,SIEN,"","~~~~~NOTES~BMXADOFD~53")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
RENT ; ITERATE IN CHUNKS
+1 ; RE-ITERATE USING THE "B" INDEX
+2 ; START WITH PT IEN 5 AS THE "SEED", STOP AFTER PATIENT NAME = "D", MAX # RECORDS RETURNED = 5
+3 NEW OUT,%,SIEN,SEED,LSEED,X,Y
+4 SET SEED=0
SET LSEED=""
+5 SET SIEN=$$SCHEMA("IHS PATIENT")
RIT FOR
Begin DoDot:1
+1 ; D SS^BMXADO(.OUT,SIEN,SEED,"B~CA~CB~5")
+2 DO SS^BMXADO(.OUT,SIEN,SEED,"~~~5")
+3 DO DISP(OUT)
READ %:$GET(DTIME,60)
IF '$TEST
SET SEED=""
QUIT
+4 IF %?1"^"
SET SEED=""
QUIT
+5 SET X=$PIECE(@OUT@(1),U,1)
+6 SET SEED=$PIECE(X,"|",3)
+7 IF SEED=LSEED
SET SEED=""
QUIT
+8 SET LSEED=SEED
+9 KILL ^TMP("BMX ADO",$JOB)
+10 QUIT
End DoDot:1
IF '$GET(SEED)
QUIT
+11 QUIT
+12 ;
SUB ; SUBFILE ITERATION
+1 ; THE SCHEMA IS ATTACHED TO THE MEDICARE ELIGIBILITY FILE/ELIG DATE SUBFILE
+2 ; THE DA STRING HAS A VALUE OF '1,',: THE IEN IN THE PARENT FILE.
+3 ; NOTE THE COMMA IN THE DA STRING. THIS INDICATES THAT THE FILE IEN IS 1 BUT THE SUBFILE IEN IS UNSPECIFIED
+4 NEW OUT,%,SIEN
+5 SET SIEN=$$SCHEMA("UPDATE MEDICARE DATES")
+6 DO SS^BMXADO(.OUT,SIEN,"1,","~~~")
+7 DO DISP(OUT)
READ %:$GET(DTIME,60)
+8 KILL ^TMP("BMX ADO",$JOB)
+9 QUIT
+10 ;
DINUM ; DINUMED POINTER ITERATION
+1 ; THE SCHEMA IS ATTACHED TO THE IHS PATIENT FILE (9000001)
+2 ; THE IHS PATIENT FILE IS DINUM'D AND ITS .01 FIELD POINTS TO THE VA PATIENT FILE (2)
+3 ; BECAUSE OF THE SPECIAL RELATIONSHIP BETWEEN THE FILES, WE CAN USE THE B INDEX OF FILE 2 TO ITERATE FILE 9000001.
+4 NEW OUT,%,SIEN
+5 SET SIEN=$$SCHEMA("IHS PATIENT")
+6 DO SS^BMXADO(.OUT,SIEN,"","B~A~B~5")
+7 DO DISP(OUT)
READ %:$GET(DTIME,60)
+8 KILL ^TMP("BMX ADO",$JOB)
+9 QUIT
+10 ;
IXP ; INDEXED POINTER ITERATION
+1 ; THE SCHEMA IS ATTACHED TO THE V POV FILE
+2 ; THE AC CROSS REFERENCE INDEXES THE PATIENT FIELD
+3 ; BY STARTING AND STOPING WITH PATIENT 1 (MAX=5) WE COLLECT THE FIRST 5 POVS FOR PATIENT 1 IN THE FILE
+4 NEW OUT,%,SIEN
+5 SET SIEN=$$SCHEMA("VIEW POVS")
+6 DO SS^BMXADO(.OUT,SIEN,"","AC~1~1~5")
+7 DO DISP(OUT)
READ %:$GET(DTIME,60)
+8 KILL ^TMP("BMX ADO",$JOB)
+9 QUIT
+10 ;
AA ; ITERATE USING AA INDEX
+1 ; INDEX IS 'AA" THE START AND STOP DATES ARE SPECIFIED IN EXTERNAL FORMAT. MAX=10
+2 ; THE FOLLOWING FILTERS ARE SPECIFIED IN THE LAST PARAMETER ("1|WT|C"):
+3 ; 1=PATIENT DFN #1
+4 ; WT=RETURN ONLY WEIGHTS. MEASUREMENT TYPE MUST BE SPECIFIED WITH A VALID, UNAMBIGUOUS LOOKUP VALUE.
+5 ; C=RETRUN VALUES IN CHRONOLOGICAL ORDER USE 'R' INSTEAD OF 'C' FOR REVERSE CHRONOLOGICAL ORDER. DEFAULT=C
+6 ; THE SEED PARAMTER IS SET AND CAN BE USED TO RETURN DATA IN CHUNKS
+7 NEW OUT,%,SIEN
+8 SET SIEN=$$SCHEMA("VIEW MEASUREMENTS")
+9 DO SS^BMXADO(.OUT,SIEN,"","AA~3/21/1985~6/4/1986~5~~~~1|WT|C")
+10 DO DISP(OUT)
READ %:$GET(DTIME,60)
+11 KILL ^TMP("BMX ADO",$JOB)
+12 QUIT
+13 ;
AA2 ; ITERATE USING AA INDEX
+1 ; THIS SCHEMA IS ATTACHED TO THE VISIT FILE (9000010)
+2 ; IN THIS CASE THERE IS NO ATTRIBUTE TYPE SO THE FILTER PARAM HAS ONLY 2 PIECES "1|R"
+3 ; 1=PATIENT DFN
+4 ; R=RETURN DATA IN REVERSE CHRONOLOGICAL ORDER
+5 NEW OUT,%,SIEN
+6 SET SIEN=$$SCHEMA("VISITS")
+7 DO SS^BMXADO(.OUT,SIEN,"","AA~3/21/1985~6/4/1986~5~~~~1|R")
+8 DO DISP(OUT)
READ %:$GET(DTIME,60)
+9 KILL ^TMP("BMX ADO",$JOB)
+10 QUIT
+11 ;
CIT ; CUSTOM ITERATOR
+1 ; IF COMPLEX OR UNUSUAL SORTING/FILTERING IS REQUITED, USE A CUSTOM ITERATOR
+2 ; THE CUSTOM ITERATOR IS DEFINED BY 6TH, 7TH AND 8TH PIECES IN THE VSTG
+3 ; PIECE 8=TAG, PIECE 9=ROUTINE, PIECE 8=A PARAMETER PASSED TO THE ENTRY POINT
+4 ; THE 9TH PIECE CONTAINS PT DFN, TIMESTAMP, VISIT TYPE, LOC IEN, AND SERVICE CATEGORY IN A "|" DELIMTED STRING
+5 ; THE ITERATOR CALL TAG^ROUTINE(PARAM) TO GENERATE IENS
+6 ; IN THIS CASE THE SCHEMA IS ATTACHED TO THE VISIT FILE.
+7 ; GIVEN THE INFORMATION IN THE PARAMETER, THE CUSTOM ITERATOR RETURNS POSSIBLE DUPLICATE VISITS
+8 NEW OUT,%,SIEN
+9 SET SIEN=$$SCHEMA("VISITS")
+10 DO SS^BMXADO(.OUT,SIEN,"","~~~~~DUPV~BMXADOV2~1|4/19/04@1PM|I|4585|A~")
+11 DO DISP(OUT)
READ %:$GET(DTIME,60)
+12 KILL ^TMP("BMX ADO",$JOB)
+13 QUIT
+14 ;
TRIGGER ; TEXT TRIGGER FUNCTION
+1 NEW OUT,%,SIEN
+2 SET SIEN=$$SCHEMA("PATIENT DEMOGRAPHICS")
+3 DO SS^BMXADO(.OUT,SIEN,"","~1~5")
+4 DO DISP(OUT)
READ %:$GET(DTIME,60)
+5 KILL ^TMP("BMX ADO",$JOB)
+6 QUIT
+7 ;
ID ; IDENTIFIER FIELD
+1 ; THE SCHEMA IS ATTACHED TO THE VA PATIENT FILE (2)
+2 ; THE SCHEMA HAS A BUILT IN FIELD (.01ID) THAT RETURNS THE IDENTIFIERS
+3 ; THE ENTRY POINT THAT GENERATES THE IDETIFIERS IS STORED IN THE BMX ADO SCHEMA FILE
+4 NEW OUT,%,SIEN
+5 SET SIEN=$$SCHEMA("UPDATE PATIENT DEMOGRAPHICS")
+6 DO SS^BMXADO(.OUT,SIEN,"","~1~1~")
+7 DO DISP(OUT)
READ %:$GET(DTIME,60)
+8 KILL ^TMP("BMX ADO",$JOB)
+9 QUIT
+10 ;
JMD ; JOIN MASTER TO DETAIL
+1 NEW OUT,%,SIEN1,SIEN2,VSTG,SIEN3,JSTG
+2 SET SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
+3 SET SIEN2=$$SCHEMA("VIEW MEASUREMENTS")
+4 SET SIEN3=$$SCHEMA("VIEW MEDS")
+5 ; INSTRUCTIONS FOR GATHERING DATA SET FOR PTS 1-5 FROM THE MASTER FILE
SET VSTG="~1~5"
+6 ; + INSTRUCTIONS FOR 1ST JOIN TO GET MEDS
SET JSTG=SIEN3_",.001,.02IEN,AA~1/1/1960~6/30/2004~~~~~|C"
+7 ; + INSTRUCTIONS FOR 2ND JOIN TO GET MSRMNTS
SET JSTG=JSTG_"@JOIN@"_SIEN2_",.001,.02IEN,AA~1/1/1988~12/31/1988~~~~~|WT|R"
+8 DO SS^BMXADO(.OUT,SIEN1,"",VSTG,JSTG)
+9 DO DISP(OUT)
READ %:$GET(DTIME,60)
+10 KILL ^TMP("BMX ADO",$JOB)
+11 QUIT
+12 ;
JVPT ; JOIN PT DEMOG TO VISIT
+1 NEW OUT,%,SIEN1,SIEN2,VSTG,JSTG
+2 SET SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
+3 SET SIEN2=$$SCHEMA("VISITS")
+4 ; INSTRUCTIONS FOR GATHERING DATA SET FOR PT 5 FROM THE MASTER FILE
SET VSTG="~1~1"
+5 ; + INSTRUCTIONS FOR 1ST JOIN TO GET VISIT INFO
SET JSTG=SIEN2_",.05IEN,.001,AC"
+6 DO SS^BMXADO(.OUT,SIEN1,"",VSTG,JSTG)
+7 DO DISP(OUT)
READ %:$GET(DTIME,60)
+8 KILL ^TMP("BMX ADO",$JOB)
+9 QUIT
+10 ;
JAC ; TEST AC INDEX
+1 NEW OUT,%,SIEN1,SIEN2
+2 SET SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
+3 SET SIEN2=$$SCHEMA("VIEW LABS")
+4 SET SIEN3=$$SCHEMA("VIEW MEASUREMENTS")
+5 DO SS^BMXADO(.OUT,SIEN1,"","~3~5~~~~~~"_SIEN2_",.001,.02IEN,AC@JOIN@"_SIEN3_",.001,.02IEN,AC")
+6 DO DISP(OUT)
READ %:$GET(DTIME,60)
+7 KILL ^TMP("BMX ADO",$JOB)
+8 QUIT
+9 ;
JPB ; TEST AA INDEX JOINS FOR PROBLEM LIST
+1 NEW OUT,%,SIEN1,SIEN2
+2 SET SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
+3 SET SIEN2=$$SCHEMA("VIEW PROBLEMS")
+4 DO SS^BMXADO(.OUT,SIEN1,"","~1~5~~~~~~"_SIEN2_",.001,.02IEN,AA")
+5 DO DISP(OUT)
READ %:$GET(DTIME,60)
+6 KILL ^TMP("BMX ADO",$JOB)
+7 QUIT
+8 ;
JSUB ; SUBFILE JOIN
+1 ; IN THIS CASE THE RECORDS IN A PARENT FILE ARE "JOINED" TO THE RECORDS IN ONE OF ITS SUB FILES
+2 ; THE SCHEMA IS ATTACHED TO THE "MEDICARE ELIGIBLE" FILE
+3 ; IT IS JOINED TO ITS SUBFILE, "ELIG DATES", VIA THE UPDATE MEDICARE DATES SCHEMA
+4 NEW OUT,%,SIEN1,SIEN2
+5 SET SIEN1=$$SCHEMA("UPDATE MEDICARE INFO")
+6 SET SIEN2=$$SCHEMA("UPDATE MEDICARE DATES")
+7 DO SS^BMXADO(.OUT,SIEN1,"","~1~5~~~~~~"_SIEN2_",SUB")
+8 DO DISP(OUT)
READ %:$GET(DTIME,60)
+9 KILL ^TMP("BMX ADO",$JOB)
+10 QUIT
+11 ;
ADD ; ADD A NEW ENTRY
+1 ; THIS IS A 2 STEP PROCESS:
+2 ; FIRST GET THE SCHEMA FOR THE FILE YOU WISH TO UPDATE
+3 ; THIS SCHEMA TYPICALLY BEGINS WITH THE WORD "UPDATE"
+4 ; IT CONTAINS NO ID IR IEN FIELDS
+5 ; SECOND ADD THE DATA NODE TO THE ARRAY
+6 ; IT HAS THE SAME FORMAT AS A DATA STRING ASSOCIATED WITH THE SCHEMA EXCEPT THE FIRST "^" PIECE IS NULL
+7 ; THIS PIECE CORRESPONDS TO THE IEN OF THE RECORD. SINCE THE RECORD HASNOT BEEN ADDED YET, IT IS NULL.
+8 ; IN THE DATA STRING, ALL POINTER VALUES ARE PRECEDED BY THE '`' CHARACTER AND EA. STRING ENDS IN $C(30)
+9 ; MULTIPLE DATA STRINGS CAN BE APPENDED AS NEW NODES AT THE BOTTOM OF THE ARRAY
+10 ; IN THIS CASE WE ARE ADDING A RECORD TO THE V MEASUREMENT FILE
+11 ; DATA STRING="^MEASUREMENT TYPE IEN^PATIENT DFN^VISIT IEN^RESULT"_$C(30)
+12 ; THERE ARE 2 INPUT PARAMS:
+13 ; THE CLOSED REF WHERE THE INPUT ARRAY IS STORED
+14 ; SINCE IT IS PASSED BY REFERENCE "OUT" CAN BE NULL OR UNDEFIEND.
+15 ; OUT WILL BE DEFINED AT THE CONCLUSION OF THE TRANSACTION.
+16 ; THE OUTPUT IS IN THE OUT ARRAY
+17 ; OUT(1)="OK|ien" WHERE ien IS THE IEN OF THE RECORD THAT HAS BEE ADDED.
+18 ; IF THE TRANSACTION FAILED, AN ERROR MSG WILL BE IN THE OUT ARRAY
+19 ;
+20 NEW OUT,%,SIEN,NODE
+21 SET SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
+22 ; GET SCHEMA
DO SS^BMXADO(.OUT,SIEN,"","")
+23 SET NODE=$ORDER(^TMP("BMX ADO",$JOB,999999),-1)+1
+24 SET ^TMP("BMX ADO",$JOB,NODE)="^`2^`1^`71164^175.75"_$CHAR(30)
+25 ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
DO DISP(OUT)
READ %:$GET(DTIME,60)
+26 ; EP FOR UPDAING THE RECORD
DO BAFM^BMXADOF1(.OUT,$NAME(^TMP("BMX ADO",$JOB)))
+27 KILL ^TMP("BMX ADO",$JOB)
+28 ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
WRITE !!,OUT
SET %=0
FOR
SET %=$ORDER(OUT(%))
IF '%
QUIT
WRITE !,OUT(%)
+29 QUIT
+30 ;
DELREC ; DELETE AN ENTRY
+1 ; THE SIMPLEST WAY TO DELETE AN ENTRY IS TO PUT THE RECORD IEN IN THE DA STRING PRECEDED BY A MINUS SIGN
+2 ; YOU CAN ALSO SET THE VALUE OF THE .01 FIELD TO "@"
+3 ; IF THE VALUE OF THE .01 FIELD IS NULL AND THE DA STRING IS NOT PRECEDED BY A MINUS SIGN, THE TRANSACTION WILL BE CANCELLED
+4 ; IF THE DA STRING IS NULL, THE TRANSACTION WILL BE CANCELLED
+5 NEW OUT,%,SIEN,NODE,DEL
+6 SET DEL=51385
+7 SET SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
+8 ; GET SCHEMA
DO SS^BMXADO(.OUT,SIEN,"","")
+9 SET NODE=$ORDER(^TMP("BMX ADO",$JOB,999999),-1)+1
+10 SET ^TMP("BMX ADO",$JOB,NODE)="-"_DEL_$CHAR(30)
+11 ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
DO DISP(OUT)
READ %:$GET(DTIME,60)
+12 ; EP FOR UPDAING THE RECORD
DO BAFM^BMXADOF1(.OUT,$NAME(^TMP("BMX ADO",$JOB)))
+13 KILL ^TMP("BMX ADO",$JOB)
+14 ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
WRITE !!,OUT
SET %=0
FOR
SET %=$ORDER(OUT(%))
IF '%
QUIT
WRITE !,OUT(%)
+15 QUIT
+16 ;
EDIT ; EDIT AN EXISTING ENTRY
+1 ; SIMILAR TO ABOVE EXCEPT THAT THE FIRST "^" PIECE OF THE DATA NODE IS THE IEN OF THE RECORD TO BE EDITIED
+2 ; NOTE THAT THERE IS NO '`' IN FRONT OF THE FIRST PIECE. IT IS A PURE INTEGER
+3 NEW OUT,%,SIEN,NODE
+4 SET SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
+5 ; GET SCHEMA
DO SS^BMXADO(.OUT,SIEN,"","")
+6 SET NODE=$ORDER(^TMP("BMX ADO",$JOB,999999),-1)+1
+7 SET ^TMP("BMX ADO",$JOB,NODE)="51385^^^^176^`6"_$CHAR(30)
+8 ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
DO DISP(OUT)
READ %:$GET(DTIME,60)
+9 ; EP FOR UPDAING THE RECORD
DO BAFM^BMXADOF1(.OUT,$NAME(^TMP("BMX ADO",$JOB)))
+10 KILL ^TMP("BMX ADO",$JOB)
+11 ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
WRITE !!,OUT
SET %=0
FOR
SET %=$ORDER(OUT(%))
IF '%
QUIT
WRITE !,OUT(%)
+12 QUIT
+13 ;
DELVAL ; DELETE A VALUE IN A FIELD
+1 ; SIMILAR TO EDIT EXCEPT THE VALUE IS "@"
+2 NEW OUT,%,SIEN,NODE
+3 SET SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
+4 ; GET SCHEMA
DO SS^BMXADO(.OUT,SIEN,"","")
+5 SET NODE=$ORDER(^TMP("BMX ADO",$JOB,999999),-1)+1
+6 SET ^TMP("BMX ADO",$JOB,NODE)="51385^^^^^@"_$CHAR(30)
+7 ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
DO DISP(OUT)
READ %:$GET(DTIME,60)
+8 ; EP FOR UPDAING THE RECORD
DO BAFM^BMXADOF1(.OUT,$NAME(^TMP("BMX ADO",$JOB)))
+9 KILL ^TMP("BMX ADO",$JOB)
+10 ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
WRITE !!,OUT
SET %=0
FOR
SET %=$ORDER(OUT(%))
IF '%
QUIT
WRITE !,OUT(%)
+11 QUIT