XBFNC ;IHS/SET/GTH - Field Numbering Conventions ; [ 10/29/2002 7:42 AM ]
;;3.0;IHS/VA UTILITIES;**9**;FEB 07, 1997
; XB*3*9 IHS/SET/GTH XB*3*9 10/29/2002
;
; Given an input of files, check the fields in the files
; for conformance to the SAC field numbering conventions.
;
; Can also print conventions.
;
Q ; F = File
; H = Header
; I = Field
; N = Node
; P = Piece
;
W !,"FileMan Field Numbering Conventions",!
D FNC,^XBDSET
Q:'$D(^UTILITY("XBDSET",$J))
NEW F
S F=0
F S F=$O(^UTILITY("XBDSET",$J,F)) Q:'F D FILE(F)
Q
;
FILE(F) ;
NEW I,H,N,P
S I=0
F S I=$O(^DD(F,I)) Q:'I I '($P(^(I,0),U,2)["C") D
. S H=0
. I +$P(^DD(F,I,0),U,2) D Q
.. I $L(I)'=4 D ERR(1)
.. D FILE(+$P(^DD(F,I,0),U,2))
..Q
. S N=$P($P(^DD(F,I,0),U,4),";",1),P=$P($P(^(0),U,4),";",2)
. I N=0 D Q
.. I $E(I)'="." D ERR(2)
.. I P'=+$P(I,".",2)!(+$P(I,".")) D ERR(3)
.. I P=10 D ERR(4)
..Q
. I $E(I)="." D ERR(5)
. I +N,N'=+$E(I,1,$L(N)) D ERR(6)
. I +N,P'=+$E(I,$L(N)+1,99) D ERR(7)
. I 'N,P'=I D ERR(8)
.Q
Q
;
ERR(E) ;
W:'H !," ",F," (",$O(^DD(F,0,"NM","")),"), ",I," (",$P(^DD(F,I,0),U,1),"), global location ",$P(^(0),U,4),$S(+P:"",1:"(Multiple)")
S H=1
W !?5,$P($T(@E),";",3),"."
Q
;
1 ;;Field number of multiple field is not 4 digits
2 ;;Field number in 0th node should begin with '.'
3 ;;Piece number in 0th node should = +$P(fld#,".",2)
4 ;;Piece 10 of 0th node should be null
5 ;;Field begins with '.' and not in 0th node
6 ;;Field number does not begin with node location
7 ;;Piece number does not match non-nodal part of field number
8 ;;Field number and piece number do not match
;
FNC ;
Q:'$$DIR^XBDIR("Y","Print conventions","N")
D ^%ZIS
Q:POP
U IO
D HELP^XBHELP("TXT","XBFNC",0),^%ZISC
Q
;
TXT ;
;;
;; -------------------------------
;; DATA DICTIONARY FIELD NUMBERING
;; AND DATA PLACEMENT CONVENTIONS
;; -------------------------------
;;
;;The following conventions for numbering fields, and placing data in pieces, is
;;extracted from a mail message dated 25 Feb 88, and is considered to be those
;;conventions referred to in the Programming Standards And Conventions paragraph
;;which states "Field numbers for FileMan files will be assigned in accordance
;;with established conventions."
;;
;; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
;;
;;1) There is a direct correlation between the field number and the node and
;;piece, and for multiples, between the field number and the sub-file number.
;;
;;2) Fields beginning with a "." are all .01-.n and are in the 0th node. Where
;;possible, files only have a 0th node. This reduces the number of disc accesses
;;required. A field number must be canonic, therefore, there is no .10 field.
;;It goes from .09 to .11. That means piece 10 will always be NULL.
;;
;;3) Where the entire entry cannot be put in one node, there are more nodes,
;;generally grouped by logically related fields into field numbers within some
;;range, say 1101-1116. These would be node 11 piece 1-16, and in this case
;;piece 10 is allowed because it is canonic.
;;
;;4) Multiple fields are always 4 digits. The first two digits are the next
;;higher group, using the example above, 11 would be the next higher group. The
;;second two digits are always 00. The subscript for that multiple is always the
;;first two digits of the multi-valued field number. 11 in this case. The
;;sub-file number is always the parent file number with the first two digits of
;;the multi-valued field number appended. If we were in file 9000001 in the
;;above example, the sub-file for field 1100 would be 9000001.11, and the
;;subscript would be 11. Now, if we added a multiple to that sub-file, as say
;;field number 1500, its sub-file would be 9000001.1115 and its subscript would
;;be 15. In the data global it would look like ^AUPNPAT(DA(1),11,DA,15,0). The
;;assigning of sub-file numbers is important, because if you let FileMan do it,
;;he will assign numbers that may fall within the number space of primary files
;;using our file number assigning logic.
;;
;;5) There are special cases that do not follow the rules, of course. On most
;;of the pointed to files, we have added a field number 9901 MNEMONIC which is
;;used on a site by site basis if you have a very high percentage of your lookups
;;to two or three entries, you can add data to the MNEMONIC field, say 1, 2, and
;;3, and instead of responding CLAREMORE to a LOCATION lookup, you can respond 1.
;;This field is in node 88 piece 1. It is 8801 so the MNEMONIC field would be
;;the same number in all dictionaries, regardless of how many fields, and field
;;numbers, a particular file had already.
;;
;;6) Computed fields, where ever possible, immediately follow the field from
;;which they are computed, and the computed field number is the same as the real
;;field followed by a 9. If the field above was .12 the computed field would be
;;.129. If you wanted more than one computed field off of .12 they would be
;;.1291 and .1292.
;;
;;7) There is another class of computed field. That is a computed field that
;;points back to the VA PATIENT file. Those fields have a .2 following the field
;;number. That indicates it is not really a computed field, but just a pointer
;;back to the VA PATIENT file.
;;
;;********************************************
XBFNC ;IHS/SET/GTH - Field Numbering Conventions ; [ 10/29/2002 7:42 AM ]
+1 ;;3.0;IHS/VA UTILITIES;**9**;FEB 07, 1997
+2 ; XB*3*9 IHS/SET/GTH XB*3*9 10/29/2002
+3 ;
+4 ; Given an input of files, check the fields in the files
+5 ; for conformance to the SAC field numbering conventions.
+6 ;
+7 ; Can also print conventions.
+8 ;
Q ; F = File
+1 ; H = Header
+2 ; I = Field
+3 ; N = Node
+4 ; P = Piece
+5 ;
+6 WRITE !,"FileMan Field Numbering Conventions",!
+7 DO FNC
DO ^XBDSET
+8 IF '$DATA(^UTILITY("XBDSET",$JOB))
QUIT
+9 NEW F
+10 SET F=0
+11 FOR
SET F=$ORDER(^UTILITY("XBDSET",$JOB,F))
IF 'F
QUIT
DO FILE(F)
+12 QUIT
+13 ;
FILE(F) ;
+1 NEW I,H,N,P
+2 SET I=0
+3 FOR
SET I=$ORDER(^DD(F,I))
IF 'I
QUIT
IF '($PIECE(^(I,0),U,2)["C")
Begin DoDot:1
+4 SET H=0
+5 IF +$PIECE(^DD(F,I,0),U,2)
Begin DoDot:2
+6 IF $LENGTH(I)'=4
DO ERR(1)
+7 DO FILE(+$PIECE(^DD(F,I,0),U,2))
+8 QUIT
End DoDot:2
QUIT
+9 SET N=$PIECE($PIECE(^DD(F,I,0),U,4),";",1)
SET P=$PIECE($PIECE(^(0),U,4),";",2)
+10 IF N=0
Begin DoDot:2
+11 IF $EXTRACT(I)'="."
DO ERR(2)
+12 IF P'=+$PIECE(I,".",2)!(+$PIECE(I,"."))
DO ERR(3)
+13 IF P=10
DO ERR(4)
+14 QUIT
End DoDot:2
QUIT
+15 IF $EXTRACT(I)="."
DO ERR(5)
+16 IF +N
IF N'=+$EXTRACT(I,1,$LENGTH(N))
DO ERR(6)
+17 IF +N
IF P'=+$EXTRACT(I,$LENGTH(N)+1,99)
DO ERR(7)
+18 IF 'N
IF P'=I
DO ERR(8)
+19 QUIT
End DoDot:1
+20 QUIT
+21 ;
ERR(E) ;
+1 IF 'H
WRITE !," ",F," (",$ORDER(^DD(F,0,"NM","")),"), ",I," (",$PIECE(^DD(F,I,0),U,1),"), global location ",$PIECE(^(0),U,4),$SELECT(+P:"",1:"(Multiple)")
+2 SET H=1
+3 WRITE !?5,$PIECE($TEXT(@E),";",3),"."
+4 QUIT
+5 ;
1 ;;Field number of multiple field is not 4 digits
2 ;;Field number in 0th node should begin with '.'
3 ;;Piece number in 0th node should = +$P(fld#,".",2)
4 ;;Piece 10 of 0th node should be null
5 ;;Field begins with '.' and not in 0th node
6 ;;Field number does not begin with node location
7 ;;Piece number does not match non-nodal part of field number
8 ;;Field number and piece number do not match
+1 ;
FNC ;
+1 IF '$$DIR^XBDIR("Y","Print conventions","N")
QUIT
+2 DO ^%ZIS
+3 IF POP
QUIT
+4 USE IO
+5 DO HELP^XBHELP("TXT","XBFNC",0)
DO ^%ZISC
+6 QUIT
+7 ;
TXT ;
+1 ;;
+2 ;; -------------------------------
+3 ;; DATA DICTIONARY FIELD NUMBERING
+4 ;; AND DATA PLACEMENT CONVENTIONS
+5 ;; -------------------------------
+6 ;;
+7 ;;The following conventions for numbering fields, and placing data in pieces, is
+8 ;;extracted from a mail message dated 25 Feb 88, and is considered to be those
+9 ;;conventions referred to in the Programming Standards And Conventions paragraph
+10 ;;which states "Field numbers for FileMan files will be assigned in accordance
+11 ;;with established conventions."
+12 ;;
+13 ;; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+14 ;;
+15 ;;1) There is a direct correlation between the field number and the node and
+16 ;;piece, and for multiples, between the field number and the sub-file number.
+17 ;;
+18 ;;2) Fields beginning with a "." are all .01-.n and are in the 0th node. Where
+19 ;;possible, files only have a 0th node. This reduces the number of disc accesses
+20 ;;required. A field number must be canonic, therefore, there is no .10 field.
+21 ;;It goes from .09 to .11. That means piece 10 will always be NULL.
+22 ;;
+23 ;;3) Where the entire entry cannot be put in one node, there are more nodes,
+24 ;;generally grouped by logically related fields into field numbers within some
+25 ;;range, say 1101-1116. These would be node 11 piece 1-16, and in this case
+26 ;;piece 10 is allowed because it is canonic.
+27 ;;
+28 ;;4) Multiple fields are always 4 digits. The first two digits are the next
+29 ;;higher group, using the example above, 11 would be the next higher group. The
+30 ;;second two digits are always 00. The subscript for that multiple is always the
+31 ;;first two digits of the multi-valued field number. 11 in this case. The
+32 ;;sub-file number is always the parent file number with the first two digits of
+33 ;;the multi-valued field number appended. If we were in file 9000001 in the
+34 ;;above example, the sub-file for field 1100 would be 9000001.11, and the
+35 ;;subscript would be 11. Now, if we added a multiple to that sub-file, as say
+36 ;;field number 1500, its sub-file would be 9000001.1115 and its subscript would
+37 ;;be 15. In the data global it would look like ^AUPNPAT(DA(1),11,DA,15,0). The
+38 ;;assigning of sub-file numbers is important, because if you let FileMan do it,
+39 ;;he will assign numbers that may fall within the number space of primary files
+40 ;;using our file number assigning logic.
+41 ;;
+42 ;;5) There are special cases that do not follow the rules, of course. On most
+43 ;;of the pointed to files, we have added a field number 9901 MNEMONIC which is
+44 ;;used on a site by site basis if you have a very high percentage of your lookups
+45 ;;to two or three entries, you can add data to the MNEMONIC field, say 1, 2, and
+46 ;;3, and instead of responding CLAREMORE to a LOCATION lookup, you can respond 1.
+47 ;;This field is in node 88 piece 1. It is 8801 so the MNEMONIC field would be
+48 ;;the same number in all dictionaries, regardless of how many fields, and field
+49 ;;numbers, a particular file had already.
+50 ;;
+51 ;;6) Computed fields, where ever possible, immediately follow the field from
+52 ;;which they are computed, and the computed field number is the same as the real
+53 ;;field followed by a 9. If the field above was .12 the computed field would be
+54 ;;.129. If you wanted more than one computed field off of .12 they would be
+55 ;;.1291 and .1292.
+56 ;;
+57 ;;7) There is another class of computed field. That is a computed field that
+58 ;;points back to the VA PATIENT file. Those fields have a .2 following the field
+59 ;;number. That indicates it is not really a computed field, but just a pointer
+60 ;;back to the VA PATIENT file.
+61 ;;
+62 ;;********************************************