Announcement

Collapse
No announcement yet.

How to obtain actual integer value????

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

  • How to obtain actual integer value????

    Hey,
    ADT messages that I receive carries Patient Account Number PID-18 and it usually begins with zeros, say 0000033568. I intend to insert this data to my MySQL DB. Is there any way that I can get only the actual value, ie jus the number (33568) without zeros while doing transform? Do suggest some tips on this. Thank you in advance.

    Regards,
    Kurian.

  • #2
    Re:How to obtain actual integer value????

    Code:
    var str = "0000033568";
    var intFormat = parseInt(str, 10);
    Hope this helps!

    Comment


    • #3
      Re:How to obtain actual integer value????

      Hey nshaik,
      I tried your script. I wrote in the format given below:

      Code:
      var str = $('PID');
      var intFormat = parseInt(str,11);
      channelMap.put('ID',$(intFormat));
      The transform variable PID carries the value 00003674296 and I hope the variable 'intFormat' will have the value 3674296. I used channelMap.put so that I can assign this value to the variable 'ID' and I can insert the same in the database. But here I am not getting the result. I tried with and without '$' in the channelMap.put function.

      Code:
      channelMap.put('ID',$(intFormat));
      Code:
      channelMap.put('ID',intFormat);
      I might be wrong, since I'm new to JavaScripts. Do suggest some tips.

      Regards,
      Kurian.

      Post edited by: kmthayil, at: 01/07/2008 21:29

      Comment


      • #4
        Re:How to obtain actual integer value????

        or is there a way that I can write "Regular Expression" for this operation? Do reply.

        Regards,
        Kurian.

        Post edited by: kmthayil, at: 01/08/2008 01:24

        Comment


        • #5
          Re:How to obtain actual integer value????

          Hey,
          Problem solved. I got a code that removes leading zeros.

          Code:
          var verify_id =  msg['PID']['PID.2']['CK.1'].toString();
          while (verify_id.charAt(0)=="0"«»)
          {
           verify_id=verify_id.substring(1,verify_id.length);
          }
          channelMap.put('unique_id',verify_id);
          Regards,
          Kurian.

          Comment


          • #6
            Re:How to obtain actual integer value????

            Glad you got it working. The sample code below puts the value in intFormat variable in channelMap.
            Code:
            var str = "0000033568";
            var intFormat = parseInt(str, 10);
            channelMap.put('ID',String(intFormat));
            logger.info('Patient Account: ' + channelMap.get('ID'));
            Post edited by: nshaik, at: 01/08/2008 07:12

            Comment

            Working...
            X