Decimal format in Javascript

It's odd that I've recently known how to do decimal format in javascript. Because, in the new change requests of our projects, I need to do on-the-fly calculation total amount once users change quantity. It seems so simple to use the built-in function of javascript but value parsing via javascript it a bit touch.

Here is the example.

view plain print about
1<!---
2    Please assume that "56.50" is in document.myForm.txtPrice.value
3    and quantity is 5.
4--->

It's the wrong using of fetching decimal value in JS.

view plain print about
1var getPrice = parseInt(document.myForm.txtPrice.value);

[More]

The powerful of DECODE in Oracle

In these days, I needed to manipulate Query statement in Oracle. Because, for database part, we don't want our CF to calculate the amount of our system. That's why we just let Oracle to do as much as database part can do. Because we don't want JRun can be more loaded because of such calculation and minor cases and we are always try to assign less process for our CF. Today, I need to develop some calculation in our projects for the following cases.

view plain print about
1<cfif ONHAND_QTY + PROJECTED_QTY GT MIN_QTY>
2    <!--- ONHAND_QTY + PROJECTED_QTY ARE GREATER THAN MIN_QTY --->
3    <cfset IsReplenish = "Y">
4<cfelse>
5    <!--- ONHAND_QTY + PROJECTED_QTY ARE NOT GREATER THAN MIN_QTY --->
6    <cfset IsReplenish = "N">
7</cfif>

[More]

Simple HL7 segment viewer with Coldfusion

In these days, I feel like myself to write simple HL7 segment view for myself. Because we need to check manually HL7 message text file with HL7 documentation whether the formation of our HL7 message file is correct or not. Another one is we gotta check the whether correct information is added into the correct segment sequence or not. That's why I need to write viewer program for saving our time to check like that.

Here is the code for HL7 message viewer

view plain print about
1<cfif StructKeyExists(form, "btnSubmit")>
2    <cfset ArrayMsg = ListToArray(msg, CHR(13), true, false)>
3    <table>
4        <tr>    
5            <cfloop from="1" to="#ArrayLen(ArrayMsg)#" index="i">
6                <cfset HL7MsgName = Mid(ArrayMsg[i], 1, 4)>
7                <cfset HL7MsgSeg = ListToArray(Mid(ArrayMsg[i], 6, Len(ArrayMsg[3])), "|", true, false)>
8                <td valign="top">
9                    <cfdump var="#HL7MsgSeg#" label="#HL7MsgName# Segment">
10                </td>
11            </cfloop>
12        </tr>
13    </table>    
14</cfif>
15
16<form action="index.cfm" method="post">
17    Paste HL7 message:<br>    
18    <textarea name="msg" style="width:100%; height:50px;"></textarea><br>
19    <input type="Submit" name="btnSubmit" value="View">
20</form>

The outcome will be as follow

HERE IS DEMO

If you found any bugs, please leave message as comment.

Refresh Database fields to appeare in Crystal Reports

Today, I'm assigned to update existing reports for our project. Honestly, we used Crystal Reports as using our report feature which isn't quite suitable for every client. Because our crystal reports is integrated with other 3rd party software which is needed to install Oracle Client into every computer. Let it be because it's out of what I'm gonna mention.

Say, the database fields in Crystal Reports isn't updated once we finished adding new fields or updating existing fields in our database. For this case, I thought we can make right-click on Database fields and refresh the list of database fields. Actually, it doesn't work at that. That's why I need to reconnect the database and attach all of tables which are needed for reports. At that time, all of fields are disappeared on crystal reports design. It's really headache.

[More]

Download Facebook video without installing addons

Before time, I know how to download Youtube video with http://keepvid.com. This site is cool because we can download all types of Youtube video without installing any addons or softwares except Java Applet. Unfortunately, we cannot download Facebook video with this site and I don't know why.

Today, I know how to download Facebook video without installing any addons. Ok, I don't waste your time and let make it short.

[More]

MAX function is kinda slow in Oracle

In these days, I'm on HL7 project for my company. In this project, most of processes are created within Oracle Stored Procedure. Most of Oracle stored procedure, we need to retrieve the last record from table. At that time, we sometimes use "MAX" built-in function of Oracle. Using "MAX" function in Oracle is very simple and cannot write complicated query to get last record from table like query after query method with RomNUM. But the one I haven't noticed is the performance of retrieving data.

That's why I've wrote two query statements and test in PLSQL developer.

Using MAX function

view plain print about
1SELECT MAX(PATIENT_ID) FROM NH_PATIENT
2
3<!--- executing time --->
40.047 seconds

Using query and query Using MAX function

view plain print about
1SELECT PATIENT_ID FROM
2 (SELECT PATIENT_ID FROM NH_PATIENT
3 ORDER BY PATIENT_ID DESC) CLONE_USER
4WHERE ROWNUM = 1
5
6<!--- executing time --->
70.031 seconds

So, we should avoid using "MAX" function if we really don't need to use.

Configure virtual directory on Tomcat

In these days, I've removed Adobe Coldfusion9 Developer version from my laptop and tried to install Railo 3.2 for testing about ORM feature of it. That's why I've installed the integrated installer of Railo. Before installation Railo, I feel I should remove existing apache from my laptop because I won't want any conflict will be come out because of Railo. Regarding Railo integrated installer documentation, it used Apache + Tomcat + Railo in it. That's why I feel I'm correct what I did.

After a few minutes, Railo is completely installed in my laptop. After that, I need to migrate my existing projects into Railo by configuration on Tomcat. That's why I need to create virtual directory on Tomcat. Well, I've posted create virtual directory in Apache and I feel create virtual directory on Tomcat will be same as what I've posted about.

Here is simple way to create virtual directory on Tomcat.

  • 1) [tomcat_install]/tomcat/conf/Catalina/localhost/
  • 2) create XML file. File name is the name of the virtual directory's name. If you created XML file name as posCFC.xml, your virtual directory will be "http://localhost/posCFC/"
  • 3) add the following coding into this XML file.
    view plain print about
    1<Context path="/POS" docBase="E:/Project/POS" debug="0" privileged="true">
    2</Context>
  • 4) Restart your Tomcat. (it's optional.)

ListToArray save my time

Currently, I'm on HL7 module for my current project. For HL7 project, we need to collect all of patient information and save it into text file. After that, we need to send this text file to another party. So we need to send all patient data by creating list value and separated by "|" as delimiters.

Here is example of MSH segment information.

view plain print about
1MSH|^~\&|HISSAH|HISSAH|PCS||201106011138||ADT^A36|AHIS00000004|P|2.3|||AL|NE|||||

For this case, we don't know how to check whether all of sequences are correct or not. If we check manually, it will take so long and not efficient for our testers and system analyst. That's why I need to write simple Coldfusion program for that. That's why I wrote the following coding.

view plain print about
1<cfset MyList = "^~\&|HISSAH|HISSAH|PCS||201106011138||ADT^A36|AHIS00000004|P|2.3|||AL|NE|||||">
2
3<cfloop index="i" list="#MyList#" delimiters="|">
4    <cfoutput>#i#</cfoutput><br>    
5</cfloop>

[More]

Top of Page