Announcement

Collapse
No announcement yet.

Hyphen in number string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hyphen in number string

    Hello,
    I am trying to use Mirth Connect to take information from an HL7 file, and Insert it into a SQL database table.

    I setup a Destination with a Connector Type of Database Writer, and am using the javascript code below to write to the database.
    The issue I am currently having is that the field I am trying to use is number string containing a hyphen. Whenever I try to insert the value into the nvarchar field in SQL, it is subtracting the numbers on each side of the hyphen, instead of inserting the actual string. For instance the value of my test data is 123-19 but it inserts 104 into the SQL field.

    I tried adding .toString at the end of the msg code, but I get an Error stating:
    TypeError: Cannot find function ToString in object 123-19.
    when I try to process the message.

    Can someone please help me figure out what I am doing wrong?
    thank you.

    var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sql server://192.168.150.39:1433/HIE_Concept','hieuser','hieuser');

    //var msg = new XML(SerializerFactory.getHL7Serializer().toXML(con nectorMessage.getEncodedData()));
    var msg = new XML(SerializerFactory.getSerializer('HL7V2').toXML (connectorMessage.getEncodedData()));

    var test1 = msg['PID']['PID.3']['PID.3.1'];

    var result = dbConn.executeUpdate("INSERT IGNORE INTO DocumentQueue (SourceID, DataTypeID, DocTypeID, ClinicalDate, Summary, DoctorID, FacilityID, DocumentData, FilePath, StatusID) VALUES (" + test1 + ", 0, 0, '', '', 0, 0, '', '', 0)");

    dbConn.close();

  • #2
    You're not escaping that "test1" variable correctly when you concatenate the SQL statement.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thank you.
      I ended up changing .....VALUES (" + test1 + ", 0.... to .....VALUES ('" + test1 + "', 0..... and it worked.

      Comment

      Working...
      X