Changeset 296 for ccr/trunk/p


Ignore:
Timestamp:
Nov 25, 2008, 5:19:24 PM (16 years ago)
Author:
George Lilly
Message:

init routine for the CCR Dictionary

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/C0CDIC.m

    r293 r296  
    9999 Q
    100100 ;
     101FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
     102 ; C0CFRTN IS PASSED BY NAME, C0CF IS PASSED BY VALUE
     103 ;
     104 N C0CFI,C0CFJ ;INNER LOOP, OUTER LOOP
     105 N C0CFN ; FIELD NAME
     106 S C0CFI=0 S C0CFJ=C0CF
     107 K @C0CFRTN ; CLEAR THE RETURN ARRAY
     108 F  Q:$P(C0CFJ,".",1)'=C0CF  D ; FOR THE C0CF FILE AND ALL SUBFILES INCLUSIVE
     109 . F  S C0CFI=$O(^DD(C0CFJ,C0CFI)) Q:+C0CFI=0  D  ; EVERY FIELD
     110 . . ;W C0CFJ," ",C0CFI,!
     111 . . S C0CFN=$P(^DD(C0CFJ,C0CFI,0),"^",1) ;PULL FIELD NAME FROM ^DD
     112 . . I $D(@C0CFRTN@(C0CFN)) D  ; IS THIS A DUPLICATE?
     113 . . . ;W "DUPLICATE FOUND! ",C0CFJ," ",C0CFI," ",C0CFN,!,@C0CFRTN@(C0CFN),!
     114 . . . S @C0CFRTN@("M",@C0CFRTN@(C0CFN),C0CFN)=C0CFJ_"^"_C0CFI
     115 . . E  S @C0CFRTN@(C0CFN)=C0CFJ_"^"_C0CFI
     116 . S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE
     117 Q
     118 ;
     119GET(GRTN,GFILE,GIEN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED
     120 ; BY NAME
     121 ;
     122 N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
     123 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
     124 D GETS^DIQ(GFILE,C0CREF,"**","","C0CTMP")
     125 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
     126 S (C0CI,C0CJ)=""
     127 F  S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ=""  D  ; FOR ALL SUBFILES
     128 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
     129 . F  S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI=""  D  ; ARRAY OF FIELDS
     130 . . ;W C0CJ," ",C0CI,!
     131 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
     132 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CTMP(C0CJ,C0CREF,C0CI) ;RETURN VALUE IN P3
     133 Q
     134 ;
     135INIT ; INITIALIZE CCR DICTIONARY BASED ON VARIABLE NAMES
     136 ;
     137 ; CHEAT SHEET FOR VARIABLE NAMES IN ^C0CDIC(170.xx,
     138 ; THIS IS WHAT WILL BE IN C0CA FOR EACH DICTIONARY ENTRY
     139 ;G1("CODING")="170^8"
     140 ;G1("DATA ELEMENT")="170^7"
     141 ;G1("DESCRIPTION")="170^3"
     142 ;G1("ID")="170^1"
     143 ;G1("M","170^8","CODING")="170.08^.01"
     144 ;G1("MAPPING METHOD")="170.08^1"
     145 ;G1("SECTION")="170^10"
     146 ;G1("SOURCE")="170^4"
     147 ;G1("STATUS")="170^9"
     148 ;G1("TYPE")="170^6"
     149 ;G1("VARIABLE")="170^.01"
     150 ;G1("XPATH")="170^2"
     151 ;
     152 N C0CZA,C0CZX,C0CN,C0CSTAT
     153 S C0CZX=0
     154 S C0CSTAT=0 ; INIT STATUS SET FLAG
     155 F  S C0CZX=$O(^C0CDIC(170,C0CZX)) Q:+C0CZX=0  D  ; FOR EACH DICT ENTRY
     156 . ;W C0CZX,!
     157 . K C0CA ; CLEAR OUT THE LAST ONE
     158 . D GET("C0CA",170,C0CZX) ; GET VARIABLE HASH
     159 . S C0CN=$$ZVALUE("VARIABLE") ;NAME OF THE VARIABLE
     160 . I $E(C0CN,1,5)="ACTOR" D SETFDA("SECTION","ACTORS") ;
     161 . I $E(C0CN,1,6)="SOCIAL" D  ;
     162 . . D SETFDA("SECTION","SOCIAL HISTORY") ;
     163 . . D SETFDA("STATUS","X") ;SOCIAL HISTORY NOT IMPLEMENTED
     164 . . S C0CSTAT=1
     165 . I $E(C0CN,1,6)="FAMILY" D  ;
     166 . . D SETFDA("SECTION","FAMILY HISTORY") ;
     167 . . D SETFDA("STATUS","X") ;FAMILY HISTORY NOT IMPLEMENTED
     168 . . S C0CSTAT=1
     169 . I $E(C0CN,1,5)="ALERT" D SETFDA("SECTION","ALERTS")
     170 . I $E(C0CN,1,5)="VITAL" D SETFDA("SECTION","VIT")
     171 . I $E(C0CN,1,7)="PROBLEM" D SETFDA("SECTION","PROBLEMS")
     172 . I $E(C0CN,1,10)="RESULTTEST" D SETFDA("SECTION","TEST")
     173 . E  I $E(C0CN,1,6)="RESULT" D SETFDA("SECTION","LABS")
     174 . I C0CN["CODEVALUE" D SETFDA("TYPE","CD") ;CODES
     175 . I C0CN["CODEVERSION" D SETFDA("TYPE","CV") ; CODE VERSION
     176 . I C0CN["CODINGSYSTEM" D SETFDA("TYPE","CS") ;CODING SYSTEM
     177 . I $$ZVALUE("STATUS")=""!'C0CSTAT D SETFDA("STATUS","N") ;BLANK STATUS TO N
     178 . I $$ZVALUE("XPATH")["/Medication/Directions/" D  ; MEDS DIRECTIONS VAR
     179 . . D SETFDA("SECTION","DIRECTIONS") ; SPECIAL SECTION FOR DIRECTIONS
     180 . E  I $$ZVALUE("XPATH")["/Medications/Medication/" D  ; ALL OTHER MEDS
     181 . . D SETFDA("SECTION","MEDS") ; A MEDS VAR
     182 . I $E(C0CN,($L(C0CN)-1),$L(C0CN))="ID" D SETFDA("TYPE","ID") ;CATCH THE IDS
     183 . I C0CN["DATETIME" D SETFDA("TYPE","DT") ; DATE/TIME VARIABLE
     184 . W "VARIABLE: ",C0CZX," ",C0CA("VARIABLE"),!
     185 . ;ZWR C0CFDA
     186 . I $D(C0CFDA) D  ; WE HAVE CHANGES ON THIS VARIABLE
     187 . . ZWR C0CFDA
     188 . . D UPDATE^DIE("","C0CFDA(C0CZX)")
     189 . . I $D(^TMP("DIERR",$J)) U $P BREAK
     190 ; ZWR C0CFDA
     191 Q
     192 ;
     193SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
     194 ; TO SET TO VALUE C0CSV.
     195 ; C0CFDA,C0CA,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
     196 ; C0CSN,C0CSV ARE PASSED BY VALUE
     197 ;
     198 N C0CSI,C0CSJ
     199 S C0CSI=$$ZFILE(C0CSN) ; FILE NUMBER
     200 S C0CSJ=$$ZFIELD(C0CSN) ; FIELD NUMBER
     201 S C0CFDA(C0CZX,C0CSI,C0CZX_",",C0CSJ)=C0CSV
     202 Q
     203ZFILE(ZFN) ; INTERNAL EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
     204 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
     205 Q $P(C0CA(ZFN),"^",1)
     206ZFIELD(ZFN) ;INTERNAL EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
     207 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
     208 Q $P(C0CA(ZFN),"^",2)
     209ZVALUE(ZFN) ;INTERNAL EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
     210 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
     211 Q $P(C0CA(ZFN),"^",3)
     212 ;
Note: See TracChangeset for help on using the changeset viewer.