6767 export_structs:: Bool ,
6868 make_all_fields_optional:: Bool ):: String where F
6969 m = match (pattern, str)
70- omopname = m[1 ]
71- _omopname = strip (omopname )
72- _omopname_lowercase = lowercase (_omopname )
73- _omopname_uppercase = uppercase (_omopname )
74- @debug (" Attempting to create a Julia type for the OMOP CDM table \" $(omopname ) \" " )
75- structname = string_casing (_omopname )
70+ cdmname = m[1 ]
71+ _cdmname = strip (cdmname )
72+ _cdmname_lowercase = lowercase (_cdmname )
73+ _cdmname_uppercase = uppercase (_cdmname )
74+ @debug (" Attempting to create a Julia type for the OMOP CDM table \" $(cdmname ) \" " )
75+ structname = string_casing (_cdmname )
7676 fields = String[]
7777 fieldcontentsraw = m[2 ]
7878 lines = strip .(split (strip (fieldcontentsraw), " \n " ))
9090 String[export_statement],
9191 String[" " ],
9292 String[" \"\"\" " ],
93- String[" OMOP table name: $(_omopname ) " ],
93+ String[" CDM table name: $(_cdmname_uppercase ) " ],
9494 String[" " ],
9595 String[" Julia struct name: $(structname) " ],
9696 String[" " ],
9797 String[" \$ (DocStringExtensions.TYPEDEF)" ],
9898 String[" \$ (DocStringExtensions.TYPEDFIELDS)" ],
9999 String[" \"\"\" " ],
100- String[" Base.@kwdef struct $(structname) <: OMOPType " ],
100+ String[" Base.@kwdef struct $(structname) <: CDMType " ],
101101 fields,
102102 String[" end" ],
103103 )
104104 output = join (output_lines, " \n " )
105- @debug (" The OMOP CDM table \" $(omopname ) \" will become the Julia struct `$(structname) `" )
105+ @debug (" The OMOP CDM table \" $(cdmname ) \" will become the Julia struct `$(structname) `" )
106106 return output
107107end
108108
@@ -113,33 +113,33 @@ end
113113 m = match (pattern, _line)
114114 field_name = m[1 ]
115115 _field_name = strip (strip (strip (field_name), Char[' \" ' ]))
116- field_omop_type = m[2 ]
116+ field_cdm_type = m[2 ]
117117 field_null_or_notnull = m[3 ]
118- field_partialtype = _omop_type_to_julia_partialtype (field_omop_type )
118+ field_partialtype = _cdm_type_to_julia_partialtype (field_cdm_type )
119119 field_fulltype = _generate_full_fieldtype (field_partialtype,
120120 field_null_or_notnull;
121121 make_all_fields_optional = make_all_fields_optional)
122122 result = " $(strip (_field_name)) ::$(strip (field_fulltype)) "
123123 return result
124124end
125125
126- @inline function _omop_type_to_julia_partialtype (omop_type ):: String
126+ @inline function _cdm_type_to_julia_partialtype (cdm_type ):: String
127127 varchar_pattern = r" ^varchar\( [\d ]*?\) $" i
128- _omop_type = lowercase (strip (omop_type ))
129- if _omop_type == " integer"
128+ _cdm_type = lowercase (strip (cdm_type ))
129+ if _cdm_type == " integer"
130130 return " Int"
131- elseif _omop_type == " date"
131+ elseif _cdm_type == " date"
132132 return " Dates.DateTime"
133- elseif _omop_type == " datetime2"
133+ elseif _cdm_type == " datetime2"
134134 return " Dates.DateTime"
135- elseif _omop_type == " float"
135+ elseif _cdm_type == " float"
136136 return " Float64"
137- elseif _omop_type == " varchar(max)"
137+ elseif _cdm_type == " varchar(max)"
138138 return " String"
139- elseif occursin (varchar_pattern, _omop_type )
139+ elseif occursin (varchar_pattern, _cdm_type )
140140 return " String"
141141 end
142- throw (ArgumentError (" Invalid value for omop_type : $(omop_type ) " ))
142+ throw (ArgumentError (" Invalid value for cdm_type : $(cdm_type ) " ))
143143end
144144
145145@inline function _generate_full_fieldtype (partial_fieldtype,
0 commit comments