Class: TypeAwareFieldGenerator
- Inherits:
-
Object
- Object
- TypeAwareFieldGenerator
- Includes:
- Utils
- Defined in:
- lib/ez7gen/service/type_aware_field_generator.rb
Constant Summary collapse
- @@REQ_LEN_3_DGTS =
@@UP_TO_3_DGTS = 1000 # up to 3 digits
3
- @@RANGE_INDICATOR =
up to 3 digits
'...'
- @@HAT =
Component separator, aka hat
'^'
- @@SUB =
Subcomponent separator
'&'
- @@MONEY_FORMAT_REGEX =
@@MONEY_FORMAT_INDICATORS = [‘Money’, ‘Balance’, ‘Charge’, ‘Adjustment’, ‘Income’, ‘Amount’, ‘Payment’,‘Cost’] @@MONEY_FORMAT_REGEX = /bMoneyb|bBalanceb|bCharge|bAdjustmentb|bIncomeb|bAmountb|bPaymentb|bCostb|bPercentageb/
/\bMoney\b|\bBalance\b|\bCharge|\bAdjustment\b|\bIncome\b|\bAmount\b|\bPayment\b|\bCost\b/
- @@PERCENT_FORMAT_REGEX =
/\bPercentage\b|%/
- @@INITIALS =
('A'..'Z').to_a
- @@GENERAL_TEXT =
'Notes'
- @@random =
Random.new
Constants included from Utils
Utils::BASE, Utils::BASE_INDICATOR, Utils::DATA_LOOKUP_MIS, Utils::PRIMARY
Instance Attribute Summary collapse
-
#pp ⇒ Object
Returns the value of attribute pp.
-
#yml ⇒ Object
Returns the value of attribute yml.
Instance Method Summary collapse
-
#AD(map, force = false) ⇒ Object
Generate HL7 AD (address) data type.
-
#apply_rules(codes, attributes) ⇒ Object
Handle range values specified by ‘…’ sequence, including empty range TODO refactor candidate.
-
#AUI(map, force = false) ⇒ Object
Authorization information.
-
#CCD(map, force = false) ⇒ Object
Charge time.
-
#CCP(map, force = false) ⇒ Object
Channel calibration parameters.
-
#CD(map, force = false) ⇒ Object
Channel definition.
-
#CE(map, force = false) ⇒ Object
Generate HL7 CE (coded element) data type.
-
#CF(map, force = false) ⇒ Object
Coded element with formatted values.
-
#CK(map, force = false) ⇒ Object
Composite ID with check digit.
-
#CM(map, force = false) ⇒ Object
Composite.
-
#CNE(map, force = false) ⇒ Object
CNE Coded with no exceptions.
-
#CNN(map, force = false) ⇒ Object
Composite ID number and name (special DT for NDL).
- #CP(map, force = false) ⇒ Object
-
#CQ(map, force = false) ⇒ Object
Composite quantity with units.
-
#CSU(map, force = false) ⇒ Object
Channel sensitivity/units.
-
#CWE(map, force = false) ⇒ Object
Coded with exceptions.
-
#CX(map, force = false) ⇒ Object
Generate HL7 CX (extended composite ID with check digit) data type.
-
#DDI(map, force = false) ⇒ Object
Daily deductible.
-
#DIN(map, force = false) ⇒ Object
Activation date.
-
#DLD(map, force = false) ⇒ Object
Generate HL7 DLD (discharge location) data type.
-
#DLN(map, force = false) ⇒ Object
Generate HHL7 DLN (driver’s license number) data type.
-
#DLT(map, force = false) ⇒ Object
Delta check.
-
#DR(map, force = false) ⇒ Object
Generates HL7 DR (date/time range) data type.
-
#DT(map, force = false) ⇒ Object
Generates an HL7 DT (date) datatype.
-
#DTN(map, force = false) ⇒ Object
Day Type and Number.
-
#ED(map, force = false) ⇒ Object
Encapsulated data.
-
#EI(map, force = false) ⇒ Object
Entity identifier.
-
#EIP(map, force = false) ⇒ Object
Parent order.
-
#ELD(map, force = false) ⇒ Object
Error segment.
-
#FC(map, force = false) ⇒ Object
Generates HL7 FC (financial class) data type.
-
#FN(map, force = false) ⇒ Object
Generates an HL7 FN (familiy name) data type.
-
#FT(map, force = false) ⇒ Object
Formatted text data.
-
#generate?(map, force = false) ⇒ Boolean
If field are X,W,B (Not Supported, Withdrawn Fields or Backward Compatible) returns false.
-
#generate_length_bound_id(maxlen, str = @@random.rand(100000000).to_s) ⇒ Object
Returns randomly generated Id of required length, of single digit id.
- #get_code_table(attributes) ⇒ Object
-
#get_coded_map(attributes) ⇒ Object
Values and Description from code table returned as a pair.
-
#get_coded_value(attributes) ⇒ Object
Value of coded table returned as as single value.
- #handle_length(codes, maxlen) ⇒ Object
- #handle_ranges(code) ⇒ Object
-
#HD(map, force = false) ⇒ Object
Generates HL7 HD (hierarchic designator) data type.
-
#ID(map, force = false) ⇒ Object
Generate HL7 ID, usually using value from code table.
-
#initialize(parser, helper_parser = nil) ⇒ TypeAwareFieldGenerator
constructor
constructor.
-
#IS(map, force = false) ⇒ Object
Generates HL7 IS (namespace id) data type.
-
#JCC(map, force = false) ⇒ Object
Generates HL7 JCC (job code/class) data type.
-
#LA1(map, force = false) ⇒ Object
Location with address information (variant 1).
-
#LA2(map, force = false) ⇒ Object
Location with address information (variant 2).
-
#MA(map, force = false) ⇒ Object
MA segment.
-
#MO(map, force = false) ⇒ Object
Generates an HL7 MO (money) data type.
-
#MOC(map, force = false) ⇒ Object
Charge to practice.
-
#MOP(map, force = false) ⇒ Object
Money or percentage.
-
#MSG(map, force = false) ⇒ Object
MSG segment.
-
#MSH(map, force = false) ⇒ Object
Generates HL7 MSG (Message Type) data type.
-
#NA(map, force = false) ⇒ Object
Numeric Array.
-
#NDL(map, force = false) ⇒ Object
Observing practitioner.
-
#NM(map, force = false) ⇒ Object
Generates an HL7 NM (numeric) data type.
-
#NR(map, force = false) ⇒ Object
Numeric Range.
-
#OCD(map, force = false) ⇒ Object
Generates an HL7 OCD (occurence) data type.
-
#OIP(map, force = false) ⇒ Object
Query input parameter list.
-
#OSD(map, force = false) ⇒ Object
Order sequence.
-
#OSP(map, force = false) ⇒ Object
Generate an HL7 OSP (occurence span) data type.
-
#PCF(map, force = false) ⇒ Object
Pre-certification required.
-
#PI(map, force = false) ⇒ Object
Person identifier.
-
#PIP(map, force = false) ⇒ Object
Privileges.
-
#PL(map, force = false) ⇒ Object
Generate an HL7 PL (person location) data type.
-
#PLN(map, force = false) ⇒ Object
Practitioner ID Numbers.
-
#PN(map, force = false) ⇒ Object
Person name.
-
#PPN(map, force = false) ⇒ Object
Performing person time stamp.
-
#PR(map, force = false) ⇒ Object
Reference pointer.
-
#PRL(map, force = false) ⇒ Object
Parent result link.
-
#PT(map, force = false) ⇒ Object
Generate HL7 S PT (processing type) data type.
-
#PTA(map, force = false) ⇒ Object
Processing type.
-
#QSC(map, force = false) ⇒ Object
QSC Query selection criteria.
-
#RCD(map, force = false) ⇒ Object
RCD Row column definition.
-
#RDT(map, force = false) ⇒ Object
RDF Table row definition.
-
#reset_map_attr(map, key, value) ⇒ Object
convention method to modify values of attirbutes.
-
#RFR(map, force = false) ⇒ Object
Reference range.
-
#RI(map, force = false) ⇒ Object
Repeat interval.
-
#RMC(map, force = false) ⇒ Object
Room coverage.
-
#SCV(map, force = false) ⇒ Object
SCV Scheduling class value pair.
-
#SI(map, force = false) ⇒ Object
Generate HL7 SI (sequence ID) data type.
-
#SN(map, force = false) ⇒ Object
Structured numeric.
-
#SPD(map, force = false) ⇒ Object
Specialty.
-
#SPS(map, force = false) ⇒ Object
Specimen source.
-
#SRT(map, force = false) ⇒ Object
Sort order.
-
#ST(map, force = false) ⇒ Object
Generate HL7 ST (string data) data type.
-
#TM(map, force = false) ⇒ Object
An Elementary Data Type Format: HH[MM[SS[.S[S[S]]]]][+/-ZZZZ] EX: 160140.761.
-
#TN(map, force = false) ⇒ Object
Generate an HL7 TN (telephone number) data type.
-
#to_datetime(map) ⇒ Object
DateTime generated with consideration of description string for dates in the future.
-
#TQ(map, force = false) ⇒ Object
Timing quantity.
-
#TS(map, force = false) ⇒ Object
Generate HL7 TS (time stamp), within number of weeks in the future or past.
-
#TX(map, force = false) ⇒ Object
Generate HL7 TX (text data) data type.
-
#UVC(map, force = false) ⇒ Object
Generate an HL7 UVC (Value code and amount) data type.
-
#VH(map, force = false) ⇒ Object
Visiting hours.
-
#VID(map, force = false) ⇒ Object
Generate an HL7 VID (version identifier) data type.
-
#VR(map, force = false) ⇒ Object
Value qualifier.
-
#WVI(map, force = true) ⇒ Object
Channel identifier.
-
#XAD(map, force = false) ⇒ Object
Generate HL7 XAD (extended address).
-
#XCN(map, force = false) ⇒ Object
Generate HL7 XCN (extended composite ID number and name for persons).
-
#XON(map, force = false) ⇒ Object
Generate an HL7 XON (extended composite name and identification number for organizations) data type.
-
#XPN(map, force = false) ⇒ Object
Generate an HL7 XPN (extended person name) data type.
-
#XTN(map, force = false) ⇒ Object
Generate HL7 XTN (extended telecommunication number).
Methods included from Utils
#blank?, #get_name_without_base, #get_segment_name, #get_type_by_name, #has_html_encoded_ch?, #is_number?, #num_to_nil, #safe_len, #sample_index
Constructor Details
#initialize(parser, helper_parser = nil) ⇒ TypeAwareFieldGenerator
constructor
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 23 def initialize(parser, helper_parser=nil) @pp = parser # Coded table value lookup profiler. Only set for custom schemas. # Custom schema has types which coming from the base schema but using coded tables from primary schema. # Also primary schemas use base type coded tables. @hp = helper_parser # dirname = File.join(File.dirname(File.expand_path(__FILE__)),'../../resources/properties.yml') propertiesFile = File.('../../resources/properties.yml', __FILE__) @yml = YAML.load_file propertiesFile end |
Instance Attribute Details
#pp ⇒ Object
Returns the value of attribute pp.
7 8 9 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 7 def pp @pp end |
#yml ⇒ Object
Returns the value of attribute yml.
7 8 9 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 7 def yml @yml end |
Instance Method Details
#AD(map, force = false) ⇒ Object
Generate HL7 AD (address) data type.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 36 def AD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # match cities, states and zips sample = @yml['address.states'].sample idx = @yml['address.states'].index(sample) #index of random element val=[] #street address (ST) (ST) val << @yml['address.streetNames'].sample #other designation (ST) val <<'' #city (ST) val << @yml['address.cities'].at(idx) #state or province (ST) val << @yml['address.states'].at(idx) #zip or postal code (ST) val << @yml['address.zips'].at(idx) #country (ID) val << @yml['address.countries'].at(idx) # address type (ID) # ot5 her geographic designation (ST) val.join(@@HAT) end |
#apply_rules(codes, attributes) ⇒ Object
Handle range values specified by ‘…’ sequence, including empty range TODO refactor candidate
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1460 def apply_rules(codes, attributes) #safety check, no codes returns an empty map return {} if blank?(codes) #index of random element idx = sample_index(codes.size) code = codes[idx][:value] description = codes[idx][:description] if (code.include?(@@RANGE_INDICATOR)) code = handle_ranges(code) end if (code.size > (maxlen = (attributes[:max_length]) ? attributes[:max_length].to_i : code.size)) #remove all codes wich values violate #codes.select! {|it| it[:value].size <= maxlen } code, description = handle_length(codes, maxlen) end # got to have code, get an id, most basic - TODO: verify this. # if(Utils.blank?(code)) # code, description = ID({},true), '' # end # return code, description # puts code + ', ' + description return {:value => code, :description => description} end |
#AUI(map, force = false) ⇒ Object
Authorization information
64 65 66 67 68 69 70 71 72 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 64 def AUI(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # authorization number (ST) ST(map, true) # date (DT) # source (ST) end |
#CCD(map, force = false) ⇒ Object
Charge time
75 76 77 78 79 80 81 82 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 75 def CCD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #<when to charge code (ID)> ID(map, force=false) # <date/time (TS)> end |
#CCP(map, force = false) ⇒ Object
Channel calibration parameters
85 86 87 88 89 90 91 92 93 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 85 def CCP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <channel calibration sensitivity correction (NM)> NM(map,true) # <channel calibration baseline (NM)> # <channel calibration time skew (NM)> end |
#CD(map, force = false) ⇒ Object
Channel definition
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 96 def CD(map, force=false) # check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #<channel identifier (WVI)> WVI(map, force=true) #<waveform source (WVS)> # <channel sensitivity/units (SCU)> #<channel calibration parameters (CCP)> # <sampling frequency (NM)> # <minimum/maximum data values (NR)> end |
#CE(map, force = false) ⇒ Object
Generate HL7 CE (coded element) data type
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 110 def CE(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) if(map[:max_length] && map[:max_length].to_i <3) # if CE Element has lenght of 2 or less use only value return ID(map, true) end #TODO: Refactor this method if (map[:description] == 'Role Action Reason' || map[:description] == 'Species Code' || map[:description] == 'Breed Code' || map[:description] == 'Production Class Code') return '' #Per requirement, PID.35 – PID.38 end val = [] # CE ce = (CE) map?.fld codes = get_coded_map(map) if(blank?(codes)) case map[:description] when 'Allergen Code/Mnemonic/Description' pair = yml['codes.allergens.icd10'].to_a.sample(1).to_h.first # randomly pick a pair val<<pair.first val<<pair.last else # TODO: only for elements that don't have look up table set the id randomly # if codetable is empty val << ((blank?(map[:codetable])) ? ID(map, true) : '') end else #identifier (ST) (ST) val<<codes[:value] #text (ST) val<<codes[:description] #name of coding system (IS) #alternate identifier (ST) (ST) #alternate text (ST) #name of alternate coding system (IS) end return val.join(@@HAT) end |
#CF(map, force = false) ⇒ Object
Coded element with formatted values
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 153 def CF(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <identifier (ID)> ID(map, true) # <formatted text (FT)> # <name of coding system (IS)> # <alternate identifier (ID)> # <alternate formatted text (FT)> # <name of alternate coding system (IS)> end |
#CK(map, force = false) ⇒ Object
Composite ID with check digit
167 168 169 170 171 172 173 174 175 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 167 def CK(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <ID number (NM)> NM(map,true) # <check digit (NM)> # <code identifying the check digit scheme employed (ID)> # < assigning authority (HD)> end |
#CM(map, force = false) ⇒ Object
Composite
178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 178 def CM(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # <penalty type (IS)> val=IS(map,true) # <penalty amount (NM)> val<<NM({},true) val.join(@@HAT) end |
#CNE(map, force = false) ⇒ Object
CNE Coded with no exceptions
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 195 def CNE(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <identifier (ST)> ^ <text (ST)> ST(map, true) # <name of coding system (IS)> # <alternate identifier(ST)> # <alternate text (ST)> # <name of alternate coding system (IS)> # <coding system version ID (ST)> # alternate coding system version ID (ST)> # <original text (ST)> end |
#CNN(map, force = false) ⇒ Object
Composite ID number and name (special DT for NDL)
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 211 def CNN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # ID number (ST) (ST) # val << ID(map, true) # family name (FN), used for ST # val << FN(map, true) # given name (ST) # val << @yml['person.names.first'].sample # second and further given names or initials thereof (ST) # val << @@INITIALS.to_a.sample # < suffix (e.g., JR or III) (ST)> ^ < prefix (e.g., DR) (ST)> # < degree (e.g., MD) (IS)> ^ < source table (IS)> PN(map, true) # < assigning authority namespace ID (IS)> # < assigning authority universal ID (ST)> # < assigning authority universal ID type (ID)> # val.join(@@SUB) end |
#CP(map, force = false) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 234 def CP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #price (MO) MO(map,true) #price type (ID) #from value (NM) #to value (NM) #range units (CE) #range type (ID) end |
#CQ(map, force = false) ⇒ Object
Composite quantity with units
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 248 def CQ(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # val =[] # <quantity (NM)> NM({},true) # val<<NM({},true) # <units (CE)> # val<<CE(map,true) # Per request with QBP_Q21 issue # CE always get values from code table 335, schema does not always specify it. # only ID part from CE is used for this data type # val<<ID(reset_map_attr(map, :codetable, '335'), true) # val<<ID(map,true) # val.join(@@HAT) # val.join(@@SUB) end |
#CSU(map, force = false) ⇒ Object
Channel sensitivity/units
267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 267 def CSU(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # < channel sensitivity (NM)> NM(map,true) # < unit of measure identifier (ST)> # < unit of measure description (ST)> # < unit of measure coding system (IS)> # < alternate unit of measure identifier (ST)> # < alternate unit of measure description (ST)> # < alternate unit of measure coding system (IS)> end |
#CWE(map, force = false) ⇒ Object
Coded with exceptions
282 283 284 285 286 287 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 282 def CWE(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <identifier (ST)> # <text (ST)> ^ <name of coding system (IS)> ^ <alternate identifier(ST)> ^ <alternate text (ST)> ^ <name of alternate coding system (IS)> ^ <coding system version ID (ST)> ^ alternate coding system version ID (ST)> ^ <original text (ST)> end |
#CX(map, force = false) ⇒ Object
Generate HL7 CX (extended composite ID with check digit) data type.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 290 def CX(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #ID (ST) ST(reset_map_attr(map, :description, 'Number'), true) #check digit (ST) (ST) #code identifying the check digit scheme employed (ID) #assigning authority (HD) #identifier type code (ID) (ID) #assigning facility (HD) #effective date (DT) (DT) #expiration date (DT) end |
#DDI(map, force = false) ⇒ Object
Daily deductible
306 307 308 309 310 311 312 313 314 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 306 def DDI(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # < delay days (NM)> # < amount (NM)> NM(map,true) # < number of days (NM)> end |
#DIN(map, force = false) ⇒ Object
Activation date
317 318 319 320 321 322 323 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 317 def DIN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # date < date (TS)> TS(map,true) # <institution name (CE)> end |
#DLD(map, force = false) ⇒ Object
Generate HL7 DLD (discharge location) data type. This type consists of the following components=>
326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 326 def DLD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] #discharge location (ID) val<<ID(map, true) #effective date (TS) val<<TS({},true) val.join(@@HAT) end |
#DLN(map, force = false) ⇒ Object
Generate HHL7 DLN (driver’s license number) data type
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 339 def DLN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # DLN dln = (DLN) map.fld #Driver´s License Number (ST) val << generate_length_bound_id(10) # 10 vs 7 Numeric, as for some states in real life #Issuing State, province, country (IS) #is(['fld'=>dln.getIssuingStateProvinceCountry(), 'required'=>'R','codetable'=>map.codetable]) #dln.getIssuingStateProvinceCountry().setValue(allStates.get(Math.abs(random.nextInt()%allStates.size()))) # val << @yml['address.states'].sample # pick a state # val << @yml['address.states'].sample # pick a state val << IS({:codetable =>'333'},true) # pick a state #expiration date (DT) val << DT(reset_map_attr(map, :description, 'End'), true) val.join(@@HAT) end |
#DLT(map, force = false) ⇒ Object
Delta check
359 360 361 362 363 364 365 366 367 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 359 def DLT(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <range (NR)> NR(map,true) # <numeric threshold (NM)> # <change computation (ST)> # <length of time-days (NM)> end |
#DR(map, force = false) ⇒ Object
Generates HL7 DR (date/time range) data type.
370 371 372 373 374 375 376 377 378 379 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 370 def DR(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] #range start date/time (TS) val<<TS(map,true) #range end date/time (TS) val<<TS(reset_map_attr(map, :description, 'End'), true) val.join(@@HAT) end |
#DT(map, force = false) ⇒ Object
Generates an HL7 DT (date) datatype.
382 383 384 385 386 387 388 389 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 382 def DT(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) is_year_only = (map[:max_length]) ? map[:max_length].to_i == 4 : false # #time of an event (TSComponentOne) (is_year_only)? to_datetime(map).strftime('%Y') : to_datetime(map).strftime('%Y%m%d') #format('YYYYMMdd.SSS')Date.iso8601 end |
#DTN(map, force = false) ⇒ Object
Day Type and Number
392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 392 def DTN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # val=[] # # <day type (IS)> # val<<IS(map,true) # per Galina request: Ensemble limits the length of IN3.11 to 3. So, we need to remove the second component from being populated ... IS(map,true) # # <number of days (NM)> # val<<NM({},true) # val.join(@@HAT) end |
#ED(map, force = false) ⇒ Object
Encapsulated data
407 408 409 410 411 412 413 414 415 416 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 407 def ED(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <source application (HD) > HD(map, true) # <type of data (ID)> # <data subtype (ID)> # <encoding (ID)> # <data (ST)> end |
#EI(map, force = false) ⇒ Object
Entity identifier
419 420 421 422 423 424 425 426 427 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 419 def EI(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <entity identifier (ST)> ST(map,true) # <namespace ID (IS)> # <universal ID (ST)> # < universal ID type (ID)> end |
#EIP(map, force = false) ⇒ Object
Parent order
430 431 432 433 434 435 436 437 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 430 def EIP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <parent’s placer order number (EI)> EI(map,true) # <parent’s filler order number (EI)> end |
#ELD(map, force = false) ⇒ Object
Error segment
440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 440 def ELD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] # <segment ID (ST)> val<<'' # <sequence (NM)> val<<'' # <field position (NM)> val<<'' # <code identifying error (CE)> val<<CE(map,true) val.join(@@HAT) end |
#FC(map, force = false) ⇒ Object
Generates HL7 FC (financial class) data type.
456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 456 def FC(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] #Financial Class (IS) val << IS(map, true) #Effective Date (TS) (TS) val << TS(map, true) val.join(@@HAT) end |
#FN(map, force = false) ⇒ Object
Generates an HL7 FN (familiy name) data type.
469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 469 def FN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #surname (ST) @yml['person.names.last'].sample #own surname prefix (ST) #own surname (ST) #surname prefix from partner/spouse (ST) #surname from partner/spouse (ST) end |
#FT(map, force = false) ⇒ Object
Formatted text data. The FT field is of arbitrary length (up to 64k) and may contain formatting commands enclosed in escape characters.
483 484 485 486 487 488 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 483 def FT(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) ID(map, true) end |
#generate?(map, force = false) ⇒ Boolean
If field are X,W,B (Not Supported, Withdrawn Fields or Backward Compatible) returns false. Conditional © ? For Optional field (O) makes random choice R - Required returns true def autoGenerate?(map, force=false)
1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1545 def generate?(map, force=false) # return true return true if(force) #forced generation, ignore mappings #look up in the mapping case map[:required] when 'X','W','B' then false; when 'R' then true; when 'O' then [true,false].sample(); else false ; end # if(['X','W','B'].include?(map[:required]))then return false end # if(map[:required] =='R') then return true end # if(map[:required] == 'O') then return true end #random boolean end |
#generate_length_bound_id(maxlen, str = @@random.rand(100000000).to_s) ⇒ Object
Returns randomly generated Id of required length, of single digit id
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1520 def generate_length_bound_id(maxlen, str=@@random.rand(100000000).to_s) idx = maxlen if(maxlen > str.size) str = str.ljust(maxlen,'0') idx = str.size end #safe fail #this handles case when maxlen is less then 1 idx = [0,idx-1].max return str[0..idx] end |
#get_code_table(attributes) ⇒ Object
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1447 def get_code_table(attributes) codeTable = get_name_without_base(attributes[:codetable]) codes = @pp.get_code_table(codeTable) # Case when we are looking for code values defined in base schema for types # which are in custom/primary schema or the othere way around. if(@hp && (codes.first == Utils::DATA_LOOKUP_MIS)) codes = @hp.get_code_table(codeTable) end return codes end |
#get_coded_map(attributes) ⇒ Object
Values and Description from code table returned as a pair.
1438 1439 1440 1441 1442 1443 1444 1445 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1438 def get_coded_map(attributes) codes = get_code_table(attributes) # puts codes #Apply rules to find a value and description #Returns map with code and description apply_rules(codes, attributes) end |
#get_coded_value(attributes) ⇒ Object
Value of coded table returned as as single value
1427 1428 1429 1430 1431 1432 1433 1434 1435 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1427 def get_coded_value(attributes) codes = get_code_table(attributes) # puts codes #Apply rules to find a value and description map = apply_rules(codes, attributes) #Return value only return map[:value] end |
#handle_length(codes, maxlen) ⇒ Object
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1489 def handle_length(codes, maxlen) idx = codes.find_index { |it| it[:value].size <= maxlen } if (!idx) code, description = '', '' else # puts codes code = codes[idx][:value] description = codes[idx][:description] end return code, description end |
#handle_ranges(code) ⇒ Object
1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1502 def handle_ranges(code) # if (code.include?(@@RANGE_INDICATOR)) ends = code.delete(' ').split('...').map { |it| it } if (ends.empty?) # This is indication that codetable does not have any values code = '' else #Handle range values, build range and pick random value # range = ends.first..ends.last # code = range.to_a.sample # per Galina: Invalid value 'Q8' appears in segment 4:PD1, field 20, repetition 1, component 1, subcomponent 1, # but does not appear in code table 2.4:141. # I think you had to fix this one before to pull only the first and the last values from each row. code = ends.sample end return code end |
#HD(map, force = false) ⇒ Object
Generates HL7 HD (hierarchic designator) data type
492 493 494 495 496 497 498 499 500 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 492 def HD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #namespace ID (IS) IS(map, true) #universal ID (ST) #universal ID type (ID) end |
#ID(map, force = false) ⇒ Object
Generate HL7 ID, usually using value from code table
504 505 506 507 508 509 510 511 512 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 504 def ID(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #value only #Case when max_len overrides requirements len = safe_len(map[:max_length], @@REQ_LEN_3_DGTS) (!blank?(map[:codetable]))? get_coded_value(map): generate_length_bound_id(len) end |
#IS(map, force = false) ⇒ Object
Generates HL7 IS (namespace id) data type
515 516 517 518 519 520 521 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 515 def IS(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #TODO: same as ID? ID(map,true) end |
#JCC(map, force = false) ⇒ Object
Generates HL7 JCC (job code/class) data type.
525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 525 def JCC(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] #job code (IS) # is(['fld'=>jcc.getComponent(0), 'required'=>'R', 'codetable'=>map.codetable]) val << IS(map, true) #job class (IS) val << IS(map, true) # is(['fld'=>jcc.getComponent(1), 'required'=>'R']) val.join(@@HAT) end |
#LA1(map, force = false) ⇒ Object
Location with address information (variant 1)
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 540 def LA1(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val =[] # <point of care (IS)> val<<IS(map,true) # <room (IS) > val<<IS({:codetable =>'303'},true) # <bed (IS)> val<<IS({:codetable =>'304'},true) # <facility (HD) > val<<HD({},true) # <location status (IS) val<<'' # <patient location type (IS)> val<<'' # <building (IS)> val<<IS({:codetable =>'307'},true) # <floor (IS)> # <address(AD)> val.join(@@HAT) end |
#LA2(map, force = false) ⇒ Object
Location with address information (variant 2)
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 564 def LA2(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val =[] # <point of care (IS)> val<<IS(map,true) # <room (IS) val<<IS({:codetable =>'303'},true) # <bed (IS)> val<<IS({:codetable =>'304'},true) # <facility (HD) > val<<HD({},true) # <location status (IS) val<<'' # <patient location type (IS)> val<<'' # <building (IS)> val<<IS({:codetable =>'307'},true) # <floor (IS)> # < street address (ST)> # <other designation (ST)> # <city (ST)> # <state or province (ST)> # <zip or postal code (ST)> # <country (ID)> # <address type (ID)> # <other geographic designation (ST)> val.join(@@HAT) end |
#MA(map, force = false) ⇒ Object
MA segment
596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 596 def MA(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <sample 1 from channel 1 (NM)> NM(map,true) # <sample 1 from channel 2 (NM)> # <sample 1 from channel 3 (NM)> # <sample 2 from channel 1 (NM)> # <sample 2 from channel 2 (NM)> # <sample 2 from channel 3 (NM)> end |
#MO(map, force = false) ⇒ Object
Generates an HL7 MO (money) data type.
611 612 613 614 615 616 617 618 619 620 621 622 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 611 def MO(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # val = [] #quantity (NM)Guarantor Household Annual Income # val << NM(reset_map_attr(map,:description,'Money'),true) #val << NM(map,true) NM(map,true) #denomination (ID) # val << 'USD' # Per request. # return val.join(@@SUB) end |
#MOC(map, force = false) ⇒ Object
Charge to practice
625 626 627 628 629 630 631 632 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 625 def MOC(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <dollar amount (MO)> MO(map,true) # <charge code (CE)> end |
#MOP(map, force = false) ⇒ Object
Money or percentage
635 636 637 638 639 640 641 642 643 644 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 635 def MOP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # <money or percentage indicator (IS)> val<<IS({:codetable =>'148'},true) # <money or percentage quantity (NM)> val<<NM({:description =>'Percentage'},true) val.join(@@HAT) end |
#MSG(map, force = false) ⇒ Object
MSG segment
647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 647 def MSG(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # <message type (ID)> val<<IS({:codetable =>'76'},true) # <trigger event (ID)> val<<IS({:codetable =>'3'},true) # <message structure (ID)> val<<IS({:codetable =>'354'},true) val.join(@@HAT) end |
#MSH(map, force = false) ⇒ Object
Generates HL7 MSG (Message Type) data type.
661 662 663 664 665 666 667 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 661 def MSH(map, force=false) #Message type set while initializing MSH segment, do nothing. #message type (ID) #trigger event (ID) #message structure (ID) end |
#NA(map, force = false) ⇒ Object
Numeric Array
671 672 673 674 675 676 677 678 679 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 671 def NA(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <value1 (NM)> NM(map,true) # <value2 (NM)> # <value3 (NM)> # <value4 (NM)> end |
#NDL(map, force = false) ⇒ Object
Observing practitioner
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 682 def NDL(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <name (CNN)> CNN(map,true) # <start date/time (TS)> # <end date/time (TS)> # <point of care (IS)> # <room (IS)> # <bed (IS)> # <facility (HD)> # <location status (IS)> # <person location type (IS)> # <building (IS)> # <floor (IS)> end |
#NM(map, force = false) ⇒ Object
Generates an HL7 NM (numeric) data type. A NM contains a single String value.
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 701 def NM(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = 0 case map[:description] when'Guarantor Household Size','Birth Order' val = generate_length_bound_id(1) when 'Guarantor Household Annual Income' val = '%.2f' % generate_length_bound_id(5) when @@MONEY_FORMAT_REGEX val = '%.2f' % ID(map,true) when @@PERCENT_FORMAT_REGEX val = @@random.rand(0..100) # generate proper % value < 100 else val = ID(map,true) # general rule for a number if (map[:datatype] == 'CP' || map[:datatype] == 'MO') # money val = '%.2f' % val end end # #money # if (!Utils.blank?(map[:description]) && @@MONEY_FORMAT_INDICATORS.index{|it| map[:description].include?(it)}) #check for specific numeric for money # val = '%.2f' % @@random.rand(@@UP_TO_3_DGTS) #under $1,000 # else #quantity (NM) # val = @@random.rand(@@UP_TO_3_DGTS).to_s #under 20 # end return val end |
#NR(map, force = false) ⇒ Object
Numeric Range
731 732 733 734 735 736 737 738 739 740 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 731 def NR(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # Low Value (NM) val=NM(map,true) # High Value (NM) val<<'' val.join(@@SUB) end |
#OCD(map, force = false) ⇒ Object
Generates an HL7 OCD (occurence) data type. The code and associated date defining a significant event relating to a bill that may affect payer processing
744 745 746 747 748 749 750 751 752 753 754 755 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 744 def OCD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] #occurrence code (IS) val << IS(map, true) # is(['fld'=>ocd.getComponent(0), 'required'=>'R', 'codetable'=>map.codetable]) #occurrence date (DT) #dt(['fld'=>ocd.getComponent(1), 'required'=>'R']) val << DT(map, true) val.join(@@HAT) end |
#OIP(map, force = false) ⇒ Object
Query input parameter list
951 952 953 954 955 956 957 958 959 960 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 951 def OIP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <segment field name (ST) > # <value1 (ST) & value2 (ST) & value3 (ST) ...> #Example: |@PID.5.1^EVANS| #TBD '' end |
#OSD(map, force = false) ⇒ Object
Order sequence
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 758 def OSD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <sequence/results flag (ID)> ID(map, force) # <placer order number: entity identifier (ST)> # <placer order number: namespace ID (IS)> # <filler order number: entity identifier (ST)> # <filler order number: namespace ID (IS)> # <sequence condition value (ST)> # <maximum number of repeats (NM)> # <placer order number: universal ID (ST)> # <placer order number; universal ID type (ID)> # <filler order number: universal ID (ST)> # <filler order number: universal ID type (ID)> end |
#OSP(map, force = false) ⇒ Object
Generate an HL7 OSP (occurence span) data type.
777 778 779 780 781 782 783 784 785 786 787 788 789 790 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 777 def OSP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] #occurrence span code (CE) # val << CE(map, true) # Per request with ADT_A05 and ADT_A06 issues val << ID(map, true) #occurrence span start date (DT) val << DT({},true) #occurrence span stop date (DT) val << DT(reset_map_attr(map, :description, 'End'), true) val.join(@@HAT) end |
#PCF(map, force = false) ⇒ Object
Pre-certification required
793 794 795 796 797 798 799 800 801 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 793 def PCF(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <pre-certification patient type (IS)> IS({:codetable =>'150'},true) # <pre-certification required> # <pre-certification window> end |
#PI(map, force = false) ⇒ Object
Person identifier
804 805 806 807 808 809 810 811 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 804 def PI(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <ID number (ST)> ST(map,true) # <type of ID number> # <other qualifying info> end |
#PIP(map, force = false) ⇒ Object
Privileges
814 815 816 817 818 819 820 821 822 823 824 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 814 def PIP(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <privilege (CE)> IS(map,true) # <privilege class (CE)> # <expiration date (DT)> # <activation date (DT)> # <facility (EI)> end |
#PL(map, force = false) ⇒ Object
Generate an HL7 PL (person location) data type.
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 828 def PL(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] #point of care (IS) val<<IS({:codetable =>'302'},true) #room (IS) val<<IS({:codetable =>'303'},true) #bed (IS) val<<IS({:codetable =>'304'},true) #facility (HD) (HD) val << HD({:codetable =>'300'}, true) #location status (IS) val << '' #person location type (IS) val << '' #building (IS) val<<IS({:codetable =>'307'},true) #floor (IS) #Location description (ST) val.join(@@HAT) end |
#PLN(map, force = false) ⇒ Object
Practitioner ID Numbers
852 853 854 855 856 857 858 859 860 861 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 852 def PLN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <ID number (ST)> ST(map,true) # <type of ID number (IS)> # <state/other qualifying info (ST)> # <expiration date (DT)> end |
#PN(map, force = false) ⇒ Object
Person name
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 865 def PN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # family name (FN) val << FN(map, true) # given name (ST) val << @yml['person.names.first'].sample # second and further given names or initials thereof (ST) val << @@INITIALS.to_a.sample # suffix (e.g., JR or III) (ST) # prefix (e.g., DR) (ST) # degree (e.g., MD) (IS) val.join(@@HAT) end |
#PPN(map, force = false) ⇒ Object
Performing person time stamp
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 882 def PPN(map, force=false) # check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] # <ID number (ST)> val << ST(map,true) # PN will work for the subset of fields used below val << PN({},true) # <family name (FN)> # <given name (ST)> # <second and further given names or initials thereof (ST)> # <suffix (e.g., JR or III) (ST)> # <prefix (e.g., DR) (ST)> # <degree (e.g., MD) (IS)> # <source table (IS)> # <assigning authority (HD)> # <name type code(ID)> # <identifier check digit (ST)> # <code identifying the check digit scheme employed (ID )> # <identifier type code (IS)> # <assigning facility (HD)> # < date/time action performed (TS)> # <name representation code (ID)> # <name context (CE)> # <name validity range (DR)> # <name assembly order (ID)> val.join(@@HAT) end |
#PR(map, force = false) ⇒ Object
Reference pointer
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1037 def PR(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <pointer (ST) > ST(map,true) # < application ID (HD)> # <type of data (ID)> # <subtype (ID)> end |
#PRL(map, force = false) ⇒ Object
Parent result link
914 915 916 917 918 919 920 921 922 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 914 def PRL(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <OBX-3-observation identifier of parent result (CE)> CE(map,true) # <OBX-4-sub-ID of parent result(ST)> # <part of OBX-5 observation result from parent (TX)see discussion> end |
#PT(map, force = false) ⇒ Object
Generate HL7 S PT (processing type) data type.
925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 925 def PT(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #map.maxlen # PT pt = (PT) map.fld # Map mp = map.clone() # mp.fld = pt.getComponent(0) # mp.required = 'R' ID(map, true) #processing ID (ID) #processing mode (ID) end |
#PTA(map, force = false) ⇒ Object
Processing type
940 941 942 943 944 945 946 947 948 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 940 def PTA(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <processing ID (ID)> ID(map, true) # <processing mode (ID)> # <processing ID (ID)> end |
#QSC(map, force = false) ⇒ Object
QSC Query selection criteria
963 964 965 966 967 968 969 970 971 972 973 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 963 def QSC(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <segment field name(ST)> # <relational operator (ID)> # <value (ST)> <relational conjunction (ID)> # Example: |@PID.5.1^EQ^EVANS|" #TBD '' end |
#RCD(map, force = false) ⇒ Object
RCD Row column definition
976 977 978 979 980 981 982 983 984 985 986 987 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 976 def RCD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <segment field name (ST)> ST(reset_map_attr(map,:codetable, '440'),true) # <HL7 data type (ID)> # <maximum column width (NM)> # Example: |@PID.5.1^ST^20|" #TBD # '' end |
#RDT(map, force = false) ⇒ Object
RDF Table row definition
990 991 992 993 994 995 996 997 998 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 990 def RDT(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] # <parameter class (IS)> # randomly generated 3-digit number # v << generate_length_bound_id(@@REQ_LEN_3_DGTS) ID({},true) end |
#reset_map_attr(map, key, value) ⇒ Object
convention method to modify values of attirbutes
1578 1579 1580 1581 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1578 def reset_map_attr(map, key, value) map[key.to_sym]=value return map end |
#RFR(map, force = false) ⇒ Object
Reference range
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1001 def RFR(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <numeric range (NR)> NR(map, true) # <administrative sex (IS) # <age range (NR)> # <gestational range (NR)> # <species (TX)> # <race/subspecies (ST)> # <conditions (TX)> end |
#RI(map, force = false) ⇒ Object
Repeat interval
1016 1017 1018 1019 1020 1021 1022 1023 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1016 def RI(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <repeat pattern (IS)> # IS(map,true) IS(reset_map_attr(map, :codetable, '335'), true) # <explicit time interval (ST)> end |
#RMC(map, force = false) ⇒ Object
Room coverage
1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1026 def RMC(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <room type> (IS) IS(map,true) # <amount type> # <coverage amount> end |
#SCV(map, force = false) ⇒ Object
SCV Scheduling class value pair
1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1061 def SCV(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] # <parameter class (IS)> val<<'' # <parameter value (ST)> # val<<ST(map,true) val<<ST(reset_map_attr(map,:codetable, '294'),true) val.join(@@HAT) end |
#SI(map, force = false) ⇒ Object
Generate HL7 SI (sequence ID) data type. A SI contains a single String value.
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1075 def SI(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #SI pt = (SI) map.fld #pt.setValue(generate_length_bound_id((map.max_length)?map.max_length.toInteger():1)) len = (!blank?(map[:max_length]))?map[:max_length].to_i : 1 # per Galina: - the set IDs should be max 4 digits, please remove all the zeros. len = (len >4 )? 4 :len generate_length_bound_id(len) end |
#SN(map, force = false) ⇒ Object
Structured numeric
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1088 def SN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val = [] # <comparator (ST)> val << '' # <num1 (NM)> val << NM(map,true) # <separator/suffix (ST)> # <num2 (NM)> val.join(@@HAT) end |
#SPD(map, force = false) ⇒ Object
Specialty
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1102 def SPD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <specialty name (ST)> ST(map,true) # <governing board (ST)> # <eligible or certified (ID)> # <date of certification (DT)> end |
#SPS(map, force = false) ⇒ Object
Specimen source
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1114 def SPS(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #<specimen source name or code (CE)> CE(map,true) # <additives (TX)> # <freetext (TX)> # <body site (CE)> # <site modifier (CE)> # <collection modifier method code (CE)> # <specimen role (CE)> end |
#SRT(map, force = false) ⇒ Object
Sort order
1129 1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1129 def SRT(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <sort-by field (ST)> # <sequencing (ID)> ID(map,true) end |
#ST(map, force = false) ⇒ Object
Generate HL7 ST (string data) data type. A ST contains a single String value.
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1139 def ST(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # TODO add provider type ln 840 ROL case map[:description] when 'Guarantor SSN','Insured’s Social Security Number','Medicare health ins Card Number','Military ID Number', 'Contact Person Social Security Number' generate_length_bound_id(9) when 'Allergy Reaction Code' yml['codes.allergens'].keys.sample() when 'Strain' #PID.35 – PID.38 should be always blank, as they deal with animals, not humans. when 'AGENT ORANGE EXPOSURE LOCATION' #ZEL.29 should be 1 digit integer. generate_length_bound_id(1) else #Case when max_len overrides requirements len = safe_len(map[:max_length], @@REQ_LEN_3_DGTS) (!blank?(map[:codetable]))? get_coded_value(map): generate_length_bound_id(len) end end |
#TM(map, force = false) ⇒ Object
An Elementary Data Type Format: HH[MM[SS[.S[S[S]]]]][+/-ZZZZ] EX: 160140.761
1164 1165 1166 1167 1168 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1164 def TM(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) to_datetime(map).strftime('%H%M%S.%L') end |
#TN(map, force = false) ⇒ Object
Generate an HL7 TN (telephone number) data type. A TN contains a single String value.
1171 1172 1173 1174 1175 1176 1177 1178 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1171 def TN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # TN tn = (TN) map.fld # tn.setValue(phones.getAt(Math.abs(random.nextInt()%phones.size()))) @yml['address.phones'].sample # pick a phone end |
#to_datetime(map) ⇒ Object
Returns DateTime generated with consideration of description string for dates in the future.
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1562 def to_datetime(map) #for Time Stamp one way to figure out if event is in the future of in the past to look for key words in description isFutureEvent = !blank?(map[:description])&& map[:description].include?('End') #so 'Role End Date/Time' seed = 365 #seed bounds duration of time to a year days = @@random.rand(seed) if(map[:description]=='Date/Time Of Birth') isFutureEvent = false years = rand(30..50) days = days + 365*years # make a person 30 years old end (isFutureEvent) ? DateTime.now().next_day(days) : DateTime.now().prev_day(days) end |
#TQ(map, force = false) ⇒ Object
Timing quantity
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1181 def TQ(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <quantity (CQ)> # CQ(reset_map_attr(map, :codetable, '335'), true) CQ(map,true) # <interval (RI) # < duration (ST)> # <start date/time (TS)> # <end date/time (TS)> # <priority (ST)> # <condition (ST)> # <text (TX)> # <conjunction component (ID)> # <order sequencing (OSD)> # <occurrence duration (CE)> # <total occurrences (NM)> end |
#TS(map, force = false) ⇒ Object
Generate HL7 TS (time stamp), within number of weeks in the future or past
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1202 def TS(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #time of an event (TSComponentOne) ts = to_datetime(map).strftime('%Y%m%d%H%M%S.%L') #format('YYYYMMDDHHSS.SSS')Date.iso8601 # TS is lenght sensetive, check max_len and trim appropriate if (ts.size > (maxlen = (map[:max_length]) ? map[:max_length].to_i : ts.size)) # puts ts # ts = ts[0,maxlen] ts = ts.slice(0...maxlen) end return ts end |
#TX(map, force = false) ⇒ Object
Generate HL7 TX (text data) data type. A TX contains a single String value.
1218 1219 1220 1221 1222 1223 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1218 def TX(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # @@GENERAL_TEXT ID(map,true) end |
#UVC(map, force = false) ⇒ Object
Generate an HL7 UVC (Value code and amount) data type.
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1226 def UVC(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val =[] # UVC uvc = ((UVC)map.fld) #value code (IS) val << IS(map, true) # is(['fld'=>uvc.getComponent(0), 'required'=>'R', 'codetable'=>map.codetable]) #value amount (NM) # nm(['fld'=>uvc.getComponent(1), 'required'=>'R']) val << NM({},true)# description confuses NM generator val.join(@@HAT) end |
#VH(map, force = false) ⇒ Object
Visiting hours
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1241 def VH(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val =[] # <start day range (ID)> val << ID(map,true) # <end day range (ID)> val << ID(map,true) # <start hour range (TM)> # <end hour range (TM)> val.join(@@HAT) end |
#VID(map, force = false) ⇒ Object
Generate an HL7 VID (version identifier) data type.
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1256 def VID(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # VID vid = ((VID)map.fld) #version ID (ID) ID(map, true) #id(['fld'=>vid.getComponent(0), 'required'=>'R', 'codetable'=>map.codetable]) # internationalization code (CE) # international version ID (CE) end |
#VR(map, force = false) ⇒ Object
Value qualifier
1270 1271 1272 1273 1274 1275 1276 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1270 def VR(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <first data code value (ST)> ST(map,true) # <Last data code value (ST)> end |
#WVI(map, force = true) ⇒ Object
Channel identifier
1279 1280 1281 1282 1283 1284 1285 1286 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1279 def WVI(map, force=true) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # <channel number (NM)> NM(map, true) # <channel name (ST)> end |
#XAD(map, force = false) ⇒ Object
Generate HL7 XAD (extended address)
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1295 def XAD(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # same as address AD AD(map,true) #street address (SAD) (SAD) #other designation (ST) #city (ST) #state or province (ST) #zip or postal code (ST) #country (ID) #address type (ID) #other geographic designation (ST) #county/parish code (IS) #census tract (IS) #address representation code (ID) #address validity range (DR) end |
#XCN(map, force = false) ⇒ Object
Generate HL7 XCN (extended composite ID number and name for persons)
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1316 def XCN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) val=[] # XCN xcn = (XCN) map.fld # ID number (ST) (ST) val << ID(map, true) # xcn.getIDNumber().setValue(Math.abs(random.nextInt() % 300).toString()) val << PN(map, true) # family name (FN) # val << FN(map, true) # given name (ST) # val << @yml['person.names.first'].sample # second and further given names or initials thereof (ST) # val << @@INITIALS.to_a.sample # suffix (e.g., JR or III) (ST) # prefix (e.g., DR) (ST) # degree (e.g., MD) (IS) # source table (IS) # assigning authority (HD) # name type code (ID) # identifier check digit (ST) # code identifying the check digit scheme employed (ID) # identifier type code (IS) (IS) # assigning facility (HD) # Name Representation code (ID) # name context (CE) # name validity range (DR) # name assembly order (ID) val.join(@@HAT) end |
#XON(map, force = false) ⇒ Object
Generate an HL7 XON (extended composite name and identification number for organizations) data type.
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1352 def XON(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # XON xtn = (XON) map.fld val=[] #organization name (ST) val << ST(map, true) # st(['fld'=>xtn.getComponent(0), 'required'=>'R', 'codetable'=>map.codetable]) #organization name type code (IS) val << '' #ID number (NM) (NM) val << NM(map, true) #nm(['fld'=>xtn.getComponent(2), 'required'=>'R']) #check digit (NM) (ST) #code identifying the check digit scheme employed (ID) #assigning authority (HD) #identifier type code (IS) (IS) #assigning facility ID (HD) #Name Representation code (ID) val.join(@@HAT) end |
#XPN(map, force = false) ⇒ Object
Generate an HL7 XPN (extended person name) data type. This type consists of the following components=>
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1376 def XPN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) # val=[] #family name (FN) # val << FN(map, true) # fn(['fld'=> xpn.getComponent(0),'required'=>'R']) #given name (ST) # val << @yml['person.names.first'].sample #xpn.givenName.setValue(firstNames.getAt(Math.abs(random.nextInt()%firstNames.size()))); #xpn.getComponent(1).setValue(firstNames.getAt(Math.abs(random.nextInt()%firstNames.size()))) #second and further given names or initials thereof (ST) # val << @@INITIALS.to_a.sample #xpn.secondAndFurtherGivenNamesOrInitialsThereof.setValue('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.getAt(Math.abs(random.nextInt()%26))) #suffix (e.g., JR or III) (ST) #prefix (e.g., DR) (ST) #degree (e.g., MD) (IS) PN(map,true) #name type code (ID) # val.join(@@HAT) end |
#XTN(map, force = false) ⇒ Object
Generate HL7 XTN (extended telecommunication number)
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 |
# File 'lib/ez7gen/service/type_aware_field_generator.rb', line 1402 def XTN(map, force=false) #check if the field is optional and randomly generate it of skip return '' if(!generate?(map, force)) #[(999)] 999-9999 [X99999][C any text] (TN) TN(map, true) #xtn.get9999999X99999CAnyText().setValue(phones.getAt(Math.abs(random.nextInt()%phones.size()))) # telecommunication use code (ID) # telecommunication equipment type (ID) (ID) # Email address (ST) # Country Code (NM) # Area/city code (NM) # Phone number (NM) # Extension (NM) # any text (ST) end |