0
// Create new object in the hash variable
var hash = new Object;

// Set wishard_modality variable to OBR.24.1
var wishard_modality = msg['OBR']['OBR.24']['OBR.24.1'].toString();

// Assign replacement values for the hash variable
hash.CAT = 'CT'; //Computed Tomography
hash.CT = 'CT'; //Computed Tomography
hash.RAD = 'CR'; //Computed Radiography
hash.CR = 'CR'; //Computed Radiography
hash.MRI = 'MR'; //Magnetic Resonance

I am trying to add

hash.999-other = 'OT';

but I get an error = Error on line 33: missing ; before statement

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
IndyMirthman
  • 21
  • 1
  • 5
  • That line is an attempt to assign to a subtraction, which doesn't make sense. You can use invalid identifiers as property names with dot notation. – jonrsharpe Dec 26 '19 at 17:44
  • 2
    Notice how you previously used `msg['OBR']['OBR.24']['OBR.24.1']` to reference non-identifier property names. – Ry- Dec 26 '19 at 17:45
  • msg['OBR']['OBR.24']['OBR.24.1'] is a portion of a HL7 message. Inside ['OBR.24.1'] is typically a two or three character entry. The portion of JS code takes the entry and just modifies it to be accepted into a naming convention. Recently I started seeing something new. 999-other, I'm supposed to convert this to just 'OT'. So if I cannot put a number after a dot operator, then I may need to add an 'if" statement. I'm confused on why my post was closed. None of the other links give me an answer. They explain why my effort has failed. But nothing to help me get passed the issue. – IndyMirthman Dec 26 '19 at 18:34

1 Answers1

0

JavaScript variable (and function) name rules:

  • Can't start with a number
  • They can contain numbers however
  • They can start with _, $ or with an alphabetical character.
  • If they start with _, it must be followed by at least one number, alphabetical character, or $.
  • They can contain alphanumerical characters, _ and $.

So the name 999-other is not allowed.

CoderCharmander
  • 1,862
  • 10
  • 18