Saturday, 14 December 2013

How to Read and Understand an EDI File ?


1.First Open the EDI File in Notepad ++
2.Copy the Character at Column 106. Mostly the Character will be tilde (~)

image
3.Then go to Search -> Replace Menu in Notepad ++
4.Paste the Character ~ in the Find What and Replace With "\n"

image
5.Click Replace All.

Now let us see how an EDI File represents the information.
For example, assume we need to Write patient Address. The patient Address is follows

59 Washington Avenue
1st Street, 5th Block
Mineola, NY 115012917

We would normally called the above as paragraph and we know paragraph are group of sentences or lines and each sentences is group of words. And also, each line is separated by new line character and each word inside the line are separated by space.

Now let us see what is the corresponding EDI Terms for the above. Paragraphs are called as Loop and and lines are called as Segments and words are called as Elements.

So Inside a loop, each segment are separated by character(it can be any character, but mostly developer will use ~) and each elements are separated by character(It can be any character, but mostly developer will use *)

N3*59 Washington Ave
N4*Mineola*NY*115012917


Paragraph Loop
Sentences or Lines Segments
Words Elements


The best way to think of an EDI claim file is like a page in a book:
The Loops tell you the paragraph
The Segments tell you the sentence
The Elements tell you the word

Monday, 9 December 2013

EDI Instructions

        

HIPAA Compliant Codes
All the Health care EDI Transaction set should use only the following HIPAA Compliant Codes

  • Physicians Current Procedure Terminology (CPT)
  • Health Care Financing Administration Common Procedural Coding System (HCPCS)
  • International Classification of Diseases Clinical Mod (ICD-9-CM) Diseases
  • Provider Taxonomy Codes
  • National Drug Code
  • *ICD-10 codes are not allowed prior to effective mandate date of October 1, 2014.

Diagnosis Codes

According to the 837P TR3, a transaction is not X12 compliant if decimal points are used in diagnosis codes. Therefore, should a diagnosis code contain a decimal point, BCBSGa will return a 999 to the  submitter indicating that the transaction has been rejected.

Address Information

P.O. mailboxes / Lock Boxes are not allowed in the Billing Provider loop. If submitted in the Billing Provider loop, then it will be returned to the submitter identifying which claim(s) have failed. The Pay-to Address loop does support P.O. Box / Lock Box addresses. Therefore, if payment is expected to be remitted to a P.O. Box / Lock Box, submit the P.O. Box / Lock Box address. Full 9-digit zip codes are required in the Billing Provider and Service Facility Location loops. If 5-digit zip codes are used in these loops, it  will be returned to the submitter identifying which claim(s) have failed



        
Questions or feedback are always welcome. You can email me at vbsenthilinnet@gmail.com.  
Looking for best Practice Management software ? Please email me.

Understanding EDI Structure


EDI Structure

Primary Levels are

1. Interchange Envelops
2. Functional Group
3. Transaction set

image

Data Element
A data element is equivalent to a field in a data dictionary. Data elements have a name, a data element number, a brief description, a data type, and a minimum and maximum length. For elements which represent codes, either a list of valid codes is included or a reference is included to a source outside of the X12 standard. Elements are separated by delimiters

Data Types

Data elements may have the following types:

N - Numeric with implied decimal point, signed.
Example: N2 indicates a numeric with two decimal places. 12.34 becomes 1234. N0 indicates in integer.
R - Decimal Number with explicit decimal point, signed.
Example: 12.34 represented in R format is 12.34. Starting with 4010, exponential notation is also supported.
ID - Identifier - A coded value, usually alphanumeric.
AN - String - alphanumeric.
DT - Date - YYMMDD. As of 4010, CCYYMMDD is also supported.
TM - Time - HHMM, with optional seconds and hundredths.
B - Binary - Any sequence of 8 bit bytes.

 

Composite Data Structure

A composite data structure consists of two or more simple data elements separated by a delimiter character known as the component data element separator. The individual component data elements in the composite may be designated as either mandatory or optional.

Segment
A segment is a logical grouping of data elements. A segment is equivalent to a record type. A segment is composed of one or more data elements or composite data structures, which are equivalent to the fields in a record. Segments start with a two or three character segment tag which identifies the segment, equivalent to a record type field. Data elements are separated by a delimiter character known as an element separator, and end with a different delimiter character known as the segment terminator.
Elements which are not assigned values in a particular instance of a segment are represented by consecutive delimiters, and such trailing delimiters are not transmitted. For example, if a segment XYX has five elements and in a particular transmission only the second has a value, it is represented as XYZ**123<CR>, where "*" is the element separator and <CR> is the segment terminator.


image

image


Delimiters
In an X12 message, the various delimiters are part of the syntax, dividing up the different elements of a message. The delimiters used in a message are defined in the interchange control header, the outermost layer enveloping the message.
For this reason, there is flexibility in the delimiters that are used. No suggested delimiters are recommended as part of the X12 standards, but the industry-specific implementation guides do have recommended delimiters.
The default delimiters  are:
Segment terminator
~ (tilde)
Data element separator
* (asterisk)
Subelement (component) separator
: (colon)
Repetition separator (version 4020 and later)
+ (plus sign)

 
Loop

Loop is a set of related segments in a Transaction Set. Segments are grouped together in this way to conveniently represent a block of related information. No formal Loops are defined, but several basic loop types, such as a Name/Address loop, appear with minor variations in many Transaction Sets. Different loops may be nested within each other, and loops may repeat up to the maximum loop occurrences specified within the Transaction Set.

Example for loop
1000A (Submitter) Loop
This loop contains submitter information.  A submitter is the entity that is sending the claims to the payer.  In most cases, this is the doctor or clinic name.

Example: NM1*41*2*DOCTORSOFFICE*****46*44444~

2010BA (Insured Patient) Loop
This loop contains the Patient (if the patient is the insured, otherwise Insured Person) Name, contract number, address, SSN (if used), and birthdate.
Example:

NM1*IL*1*DOE*JOHN*F***MI*ABC849559999~     ('MI' stands for member identification, followed by contract number)
N3*6022 VALLEY TRAIL~
N4*RUTH*MI*48883~
DMG*D8*19750101*M~                   ('DMG' stands for Demographic (Birth date) information.  Date format is CCYYMMDD)



Understanding EDI-Loops, Segments, and Elements

The best way to think of an EDI claim file is like a page in a book:
The Loops tell you the paragraph
The Segments tell you the sentence
The Elements tell you the word
All of this information together tells you the exact location of the problem.
Here's an example:
Let's say you received a rejection on a 5010 Professional claim, that states Loop 2300, Segment CLM05, Element 1. 
In EDI we would read this as Loop 2300, CLM05-1.
But what does it mean?  Let's break it down--Loop 2300--this is the Claim Information loop (all information relating to the claim, including place of service, admit/discharge dates, etc.  Okay, so we know the problem is in the Claim Information Loop.
Next is the Segment-CLM05.  The 5010 837P Implementation Guide (available from Washington Publishing Company) states
that CLM05 is for Health Care Service Location Information.
Finally, the Element-1.  Again, we consult our implementation guide--CLM05, Element 1, is for Facility Code Value, or Place of Service.  We may not know exactly what the problem is, but we know where to locate the problem in our claim file; and, since we know the field for this Loop/Segment/Element is Place of Service, we should be able to locate this in our software system.


        
Questions or feedback are always welcome. You can email me at vbsenthilinnet@gmail.com.  

What is an EDI ?

EDI X12 (Electronic Data Interchange) is data format based on ASC X12 standards. It is used to exchange specific data between two or more trading partners. Term ‘trading partner’ may represent organization, group of organizations or some other entity. In most cases it is just organization or company.
EDI X12 is governed by standards released by ASC X12 (The Accredited Standards Committee). Each release contains set of message types like invoice, purchase order, health care claim, etc. Each message type has specific number assigned to it instead of name. For example: an invoice is 810, purchase order is 850 and health care claim is 837.
Every new release contains new version number. Version number examples: 4010, 4020, 4030, 5010, 5030, 6010, etc. Major releases
start with new first number. For example: 4010 is one of the major releases, so is 5010. However 4020 is minor release. Minor releases contain minor changes or improvements over major releases. At the time of this writing 5010 is most widely used release.
How EDI Works
Doctor diagnosis the patient and provide the treatment for the identified disease. Billing Team prepare the bill(claim) and the claim is transmitted into an EDI Document format called as 837 Health care claim. Then the EDI 837 Document securely transmitted to the insurance company via clearing house.
Then the Insurance company processes the claim which comes in the electronic format and provide the necessary reimbursement for the provider for the treatment given to the patient.
Why You Need EDI – the Benefits
  • Lower costs
  • Higher efficiency
  • Improved accuracy
  • Enhanced security
  • Greater management information
        
Questions or feedback are always welcome. You can email me at vbsenthilinnet@gmail.com.  

Thursday, 10 October 2013

Medical Billing Workflow

 

     Note : In Medical Billing, people use different words for the same thing; Here are those most commonly used;

  • Doctor is also referred as Physician or Provider
  • Doctor Clinic is also referred as Doctor Office, or Physician Office or Provider Practice or Provider Facility; So facility or practice or clinic or office refers to the place where the patient meet the doctor;
  • Insurance is also referred as Payer or carrier

    Use case 1 : In House Billing 

  1. Patient Calls / Walks to the Physician(or Doctor or Provider) office to fix an Appointment.
  2. On the Appointment day, patient checked In to the office and give all the demographics information(last name, first name, DOB, address,etc) and insurance information;
  3. Doctor check the Patient Previous medical record and does the treatment to the patient for the current problem(or Disease); 
  4. Each Disease represents by a Code. That code is called ICD. It is also called Dx Codes or Problems or ICD Codes or Diagnosis Codes; So for each patient visit, doctor choose the correct ICD Code; ( ICD means International Statistical Classifications of Diseases. ICD codes are alphanumeric designations given to every diagnosis, description of symptoms and cause of death attributed to human beings.Some example for ICD Codes)
  5. Each treatment represent a code and that code is called CPT. It is also called Procedure Codes; So for each patient visit, doctor choose the correct CPT Code; (CPT means Current Procedural Terminology codes, are procedural codes published by the American Medical Association, describing what services the provider actually performed on the patient. Some example for CPT Codes)
  6. Once all the process are over, now patient leaves the doctor room. Now the doctor office to get paid for the service provided to the the patient;
  7. Since the patient has health insurance, so patient leaves(checked out) the clinic and ask the clinic to get money from the insurance company;
  8. Now the Billing department of the Clinic prepare the Bill(Claim) by entering all the necessary information. This process is called Charge entry or Charge Posting;
  9. Once the Claim is prepared and send to the Insurance company for payment; 
  10. Insurance company pays the doctor office;

 

   Use case 2 : In House Billing with Two Insurance

Many patients only have one insurance plan but it is  possible for a patient to have two or three medical insurance policies. The first insurance billed would be
the primary insurance. The next one billed would be the secondary, and the last would be the tertiary.

First the primary carrier must be billed first and then balance is billed to the second insurance carrier with the primary insurance payment  information.
If there is a third or tertiary insurance, it is billed last with payment information from the first two.

  1. Patient Calls / Walks to the Physician(or Doctor or Provider) office to fix an Appointment. 
  2. On the Appointment day, patient checked In to the office and give all the demographics information(last name, first name, DOB, address,etc) and insurance information; 
  3. Doctor check the Patient Previous medical record and does the treatment to the patient for the current problem(or Disease); 
  4. Each treatment represent a code and that code is called CPT. It is also called Procedure Codes; So for each patient visit, doctor choose the correct CPT Code; 
  5. Once all the process are over, now patient leaves the doctor room. Now the doctor office to get paid for the service provided to the the patient; 
  6. Since the patient has health insurance, so patient leaves(checked out) the clinic and ask the clinic to get money from the insurance company; 
  7. Now the Billing department of the Clinic prepare the Bill(Claim) by entering all the necessary information. This process is called Charge entry or Charge Posting; 
  8. Once the Claim is prepared and send to the Primary Insurance company for payment;  
  9. Primary Insurance company pays the doctor office; 
  10. Billing Department notified that claim has still some balance after Primary Insurance is paid. Since the Patient has another insurance (secondary), so now the billing department send the claim to the patient secondary insurance to collect the remaining balance.
  11. Secondary Insurance Process the claim and pay the remaining amount to doctor office

     Use case 3 : Self Pay

Patients who are not covered by health insurance(does not have any insurance) are considered “self pay” patients. They or the responsible party they designate are totally responsible for their own bill. Not everyone is covered by health insurance. The ones that aren’t covered are considered self pay and just like in the old days, these people must pay for their visits themselves.

  1. Patient Calls / Walks to the Physician(or Doctor or Provider) office to fix an Appointment. 
  2. On the Appointment day, patient checked In to the office and give all the demographics information(last name, first name, DOB, address,etc). 
  3. Doctor check the Patient Previous medical record and does the treatment to the patient for the current problem(or Disease); 
  4. Each treatment represent a code and that code is called CPT. It is also called Procedure Codes; So for each patient visit, doctor choose the correct CPT Code; 
  5. Once all the process are over, now patient leaves the doctor room. Now the doctor office to get paid for the service provided to the the patient; 
  6. Since the patient has health insurance, so patient leaves(checked out) the clinic and ask the clinic to get money from the insurance company; 
  7. Now the Billing department of the Clinic prepare the Bill(Claim) by entering all the necessary information. This process is called Charge entry or Charge Posting; 
  8. Once the Claim is prepared and since there is no insurance for the patient, so patient statement is generated and send to the patient for payment;  
  9. Patient Receives the Statement and Payment is made to the doctor office.
Use case 4 : Patient Responsibility

Some insurance policies pay a percentage rather than a set amount. Anywhere from 50% to 80% is very common for some insurance policies. Once they pay their  portion, there may be a patient responsibility remaining. This amount is generally billed to the patient after the insurance payment is made.
  1. Patient Calls / Walks to the Physician(or Doctor or Provider) office to fix an Appointment. 
  2. On the Appointment day, patient checked In to the office and give all the demographics information(last name, first name, DOB, address,etc). 
  3. Doctor check the Patient Previous medical record and does the treatment to the patient for the current problem(or Disease); 
  4. Each treatment represent a code and that code is called CPT. It is also called Procedure Codes; So for each patient visit, doctor choose the correct CPT Code; 
  5. Once all the process are over, now patient leaves the doctor room. Now the doctor office to get paid for the service provided to the the patient; 
  6. Since the patient has health insurance, so patient leaves(checked out) the clinic and ask the clinic to get money from the insurance company; 
  7. Now the Billing department of the Clinic prepare the Bill(Claim) by entering all the necessary information. This process is called Charge entry or Charge Posting; 
  8. Once the Claim is prepared and send to the Primary Insurance company for payment;  
  9. Primary Insurance company pays only 80 % of the Bill to the doctor office; 
  10. Since there is no other insurance for the patient and claim balance is still 20 %, so now the billing department change the responsibility of the balance to patient and patient statement is generated.
  11. Billing Department send the Statement to the Patient.
  12. Patient Receives the Statement and Payment is made to the doctor office.

     Use case 5 : Clearing House Work flow

  1. Patient Calls / Walks to the Physician(or Doctor or Provider) office to fix an Appointment.
  2. On the Appointment day, patient checked In to the office and give all the demographics information(last name, first name, DOB, address,etc.) and insurance information;
  3. Doctor check the Patient Previous medical record and does the treatment to the patient for the current problem(or Disease);
  4. Each Disease represents by a Code. That code is called ICD. It is also called Dx Codes or Problems or ICD Codes or Diagnosis Codes; So for each patient visit, doctor choose the correct ICD Code;

  5. Each treatment represent a code and that code is called CPT. It is also called Procedure Codes; So for each patient visit, doctor choose the correct CPT Code;

  6. Once all the process are over, now patient leaves the doctor room. Now the doctor office to get paid for the service provided to the the patient;

  7. Since the patient has health insurance, so patient leaves(checked out) the clinic and ask the clinic to get money from the insurance company;
  8. Now the Billing department of the Clinic prepare the Bill(Claim) by entering all the necessary information. This process is called Charge entry or Charge Posting;
  9. Once the Claim is prepared and send to the Insurance company for payment; 

  10. Billing Department using the Practice Management System (PMS), send the claim via EDI File. The EDI Transaction used to create the claim in the Electronic format is EDI 837
    Refer the Following Link to understand more on EDI 837
    What is an EDI ?
    EDI 837 Health Care Claim
  11. Once the 837 EDI File is created, then it will be send to the Clearing House.
  12. Clearing House will validate the EDI File and send to the particular insurance company.
  13. Insurance Company Process the Claim and prepare the Check (Cheque) and Statement(This statement is called Explanation of Benefits OR Remittance Advisory (EOB)          
    Refer the following Link for EOB
    EOB - An explanation of benefits 
  14. Insurance company also generates the EDI 835 File using their System. EDI 835 is electronic version of EOB.
    The Electronic Remittance Advice (ERA), or 835, is the electronic transaction which provides claim payment information in the HIPAA mandated ACSX12 005010X221A1   Format. These files are used by practices, facilities, and billing companies to Auto Posting payments into their systems.
    Refer the following link for Sample

    EDI 835 Health Care Claim Payment/Advice:
  15. Once the Check, Statement (EOB) and ERA File are ready, then insurance company first send the ERA File and EOB to the clearing house.Second , insurance company  will send the Check and copy of the EOB to the billing provider address . Third for each patient in the statement, the copy of the EOB will be emailed.
  16. Now the Billing Team download the EOB and ERA from the clearing house. If the PMS system has Auto Posting Using ERA File, then they will download the EDI File and do auto posting. If there is no auto posting Module, then they will download the EOB PDF and apply posting manually.Remember, some time, ERA/EOB file will be reach the clearing house, even before the insurance company send the payment check to the doctor.


     Use case 6 : Co-pay Work Flow

The co-payment or Co-pay is a payment defined in the insurance policy and paid by the insured person each time a medical service is accessed

Co-pay: A co-pay is usually a flat fee. For example, every time you go to the doctor you pay a 25.00 co-pay for the office visit, regardless of the level of service you receive.


A co-payment, or co-pay, is the flat amount that need to pay by the patient at the time of medical service i,e at the time time of the visit to doctor office. All insurance companies provide these costs to you up front. Insurance companies use these co-pays in part to share expenses with you.


  1. Patient walks into doctor office .
  2. People at the Reception desk ask the patient insurance card (it  is like credit card) and see any amount mention in the card as co-pay.   If not, they will do the eligibility check and see whether any co-pay is required. Insurance eligibility check will give the complete details     where insurance is active , any co-pay amount to be paid, etc..
  3. Once they determined, if co-pay amount need to be paid, then reception desk will do either of the following

       Option 1:
      
    Will collect the amount and give the Patient receipt.   
       Option 2:
       Will Inform the patient that he/she need to pay copy after the Insurance payment is over. After insurance payment is over, we will  send the  patient statement to you and then you can pay your co-pay
    amount    
       Option 3:
       Will inform the patient after the Insurance payment is over, we will send the claim to your secondary insurance and try to get  the co-pay amount.

    In most cases, doctor office will not collect the co-pay amount at the time of visit because either they may not known the exact amount or it   may be cover by the secondary insurance. Please remember, the exact co-pay amount is calculated after insurance processing the claim and will  be informed in the EOB.

  4. Billing company send the claim to Insurance company.
  5. Insurance company process the claim and if any co-pay has to paid by patient, then they will mention that amount in the EOB.
  6. Now the billing company transfer that amount from insurance side to patient side if patient does not have secondary insurance.   (Move to Patient responsibility)   if patient has secondary insurance, then they will send to secondary insurance and try to collect it from secondary insurance.   Please remember, while sending the claim to secondary insurance, we must send the patient primary insurance information and    what amount has been paid and what amount has been left over.
  7. If secondary insurance does not cover that amount, then it will be transferred to patient responsibility.

       
    Use case 7  : Deductible Workflow

    What does deductible mean in an insurance policy? It's the amount of a claim you are responsible for, before the insurance company will start paying it's share of costs.


    Some insurance policies have a deductible that must be met before the insurance will pay for any services. The amount of the deductible varies depending on the policy. The patient is responsible to pay for all
    amounts applied to the deductible.


    Simple example, once you taken the policy , insurance company says, first patient has to Pay $ 500 and then insurance will start paying for the medical services

    1. Patient walks into doctor office A.
    2. Doctor done some medical services to Patient.
    3. Billing Department send the claim to Insurance. Let the bill amount is $ 200.
    4. Insurance find that the patient has to pay $ 500 first and then they can start paying.
    5. Now the insurance company send the EOB saying $200 is Deductible. Please note, here insurance company does not pay any amount. And also the insurance company system reduces this $ 200 from $ 500 and update the record balance as $300 deductible balance
    6. Billing Department transfer this $ 200 to patient responsibility if the patient does not have secondary insurance. If the
        patient has secondary insurance, then claim send to secondary insurance for this amount.


**********************************
1. Same Patient walks into same doctor office A or doctor office B or lab.
2. Some medical Services done to Patient.
3. Billing Department send the claim to Insurance. Let the bill amount is $ 100
4. Insurance find that the patient has to pay $ 500 first and then they can start paying. And also records says $200 already met in the previous  visit.
5. Now the insurance company send the EOB saying $100 is Deductible. Please note, here insurance company does not pay any amount.
    And also the insurance company system reduces this $ 100 from $ 300 and update the record balance as $200 deductible balance.
6. Billing Department transfer this $ 100 to patient responsibility if the patient does not have secondary insurance. If the patient has secondary insurance, then claim send to secondary insurance for this amount.

**********************************

1. Same Patient walks into same doctor office A or doctor office B or lab.
2. Some medical Services done to Patient.
3. Billing Department send the claim to Insurance. Let the bill amount is $ 600
4. Insurance find that the patient has to pay $ 500 first and then they can start paying. And also records says $300 already met in the previous visit.
5. Now the insurance company send the EOB saying $200 is Deductible and Payment is $400
6. Billing Department transfer this $ 200 to patient responsibility if the patient does not have secondary insurance. If the
    patient has secondary insurance, then claim send to secondary insurance for this amount.

     Use case 8: Lab Billing

  1. Patient Calls / Walks to the Physician(or Doctor or Provider) office to fix an Appointment.
  2. On the Appointment day, patient checked In to the office and give all the demographics information(last name, first name, DOB, address,etc.)    and insurance information;
  3. Doctor check the Patient Previous medical record and does the treatment to the patient for the current problem(or Disease);
    Doctor Wants to check Blood test of the patient, so he request the patient leave the blood sample in the reception.
     
    The above steps are usually handled in EMR Software running inside the doctor office.
    Search Google : EMR lab request

  4. Patient leave the blood sample in the container provided at the reception desk. If the EMR running inside the doctor office are integrated  with Lab LIS, then via HL7, the doctor office place the order using the EMR software. if not integrated, the doctor office staff fill up  lab requisition order form manually and send to the Lab via fax or email. Some LIS System having Doctor Portal where the doctor office staff can login and place the order in the portal.

    Search Google : sample lab requisition form

  5. Every day Lab Transportation department visits the doctor office and pick the patient samples and shifted to Lab on same day.

    Search Google : Lab sample transportation

  6. Once the Lab receives the Order form, it will be assigned to the lab technician to do the blood test. Test technician checks the blood sample  and he prepares the Test result which contains various components with low/high value indication.

    Step (3) 4 are usually handled  in Lab LIS Software running inside the Lab .

  7. Now the Lab has get to paid for their work. Since the patient has insurance, so the Lab team forwards all those information with final result  to billing department to generate the claim and send to insurance company. If the LIS is integrated with Billing software, then information  are send via HL7 to the Billing software. If not, lab team manually pass the information by creating as PDF and forward that to the Billing  department.

  8. Now billing billing department receives the final result with all patient demographics information and insurance information.
    Now the Billing department of the Clinic prepare the Bill(Claim) by entering all the necessary information. This process is called Charge  entry or Charge Posting; 

  9. Once the Claim is prepared and send to the Primary Insurance company for payment;

  10. Primary Insurance company process the claim and send the payment to the Lab;

    Step 6,7,8,9 are usually handled in Practice Management Software or Medical Billing running inside the Lab or Billing company where they outsourced their work.

So three systems are involved (EMR, LIS and PMS) to do Lab Billing.  If the software supports HL7 Protocol, then the information can be easily passed between the system without manual data entry work.

HL7 is the standard to which healthcare application vendors adhere when developing application interfaces to exchange patient data. The HL7 standard defines a method of moving clinical data between independent medical applications in near real time



Example  Conversation during Patient check In process.



Jake : Calls the MyfirstHealth Landline Number.

Linda : Hello, This is Linda from MyfirstHealth Clinic . How can i help you ?

Jake : Hi Linda, My Name is Jake,I would like to meet Dr John today evening after 5 PM.

Can you please confirm doctor appointment is available ?

Linda : Sure, Let me check my records. Yes doctor is available after 5 PM. Do you like book the appointment ?

Jake : Yes Can you please make it at 5.30 PM ?

Linda : Sure. May i know you are coming first time to this clinic or you have already came ?

Jake : This is the first Time;

Linda : Good. May Know your last name, first Name and DOB to make a note in my records.

Jake : My Last Name is Jake; My First Name is : mike; and my DOB is xx/xx/xxxx.

Linda : Ok Got It. Please come 15 min before the appointment, so that we can get all your insurance information,etc.

Jake : Ok Sure.

That's all




At 5.15, Jake arrives the clinic and meet the reception the Linda.

Jake : I am jake, I've appointment with the Doctor John at 5.30 PM

Linda : Welcome Jake; Let me pull your records from the desk.

Jake : Sure

Linda : Jake. Do you have insurance to cover your illness ?

Jake : Yes. I've Insurance.

Linda : Please give your insurance information, so that after the visit, we need to send the bill to the insurance company

Jake : I am working in a company called xxx , My employer covers my health insurance. Do you want to give that insurance
information ?

Linda : Yes Please.

Jake : Here you go. Insurance Name :xxxx. Policy No :xxxx, etc.

Jake : Wait a minute. Apart from my employer insurance, i also have taken family coverage from another insurance.
Do you want to give that information also ?

Linda : Yes Please

Jake : Here you go. Insurance Name :xxxx. Policy No :xxxx, etc.

Jake : Hey apart from employer and my family, I've also have another insurance under my own name ?
Do you want to give that information also ?

Linda : Yes Please
Here what Linda does in the records She marked Employer Insurance as Primary, and Family Insurance as Secondary and Its own Insurance as third.

Jake : Hey i've question. Why you are collecting all my three insurance ?
Linda : Well, Once your visit is over, we will send the bill to your employer information company first and once we receive the payment, we will check whether still the bill has some more balance. If there is balance, then we will send the bill again to your family insurance company and so on.

Jake : Oh it is great process. I got it.

Jake : But I've stupid question if you don't mind.

Linda : Please go ahead

Jake : If you send the bill to my family insurance again, then you will get paid twice :). So you will get two payment
for one service ?

Linda : No it is not like that way it works. Once we receive the payment from your first insurance, if there is  balance, then we will send the bill to your second insurance along with the payment information of your first insurance. So your second insurance will check what is the first insurance paid and then they will pay only the remaining balance.

Jake : Wow that is great.

Jake : What happens if still there is balance in the bill, after my second insurance send the payment.

Linda : Well, since you have third insurance, we will send the bill again to your third insurance with the paid information from your first and second, so now your third insurance will know what has been paid by first and second insurance, then they will pay the remaining balance.

Jake : Wow that is really great process. You lot of work to do :)

Linda : Yes we always at your service sir.

Jake : But still I've another question if you don't mind ?
Linda : No problem. Go ahead

Jake : What happens if my bill still have balance after you paid from my third insurance ?
Linda : Well, Finally we will prepare the statement on your visit which will contains information about the service given and how much we got paid from all your insurance and at the bottom you can see how much you need to pay the balance. The statement will be mailed to you. Once you receive the statement, you can send the payment via check, or any other way.
Jake : Got It. I am done with my questions. Now what i want to do ?
Linda : Well. Please wait for 5 min. Our Nurse or Provider assistant will call you to do preliminary process.
Jake : Thank You.

Monday, 16 September 2013

ZK Dynamic Menu

Welcome Back. When i started learning ZK, one of the challenge thing for me to dynamically generate the Menu from the Database using different components of ZK. We managed using  via MVC and created all the stuff using pure java. But now thanks to MVVM and Children binding mechanism of ZK. Using that, with minimal lines of code, we can achieve the result.

This post will talk about creating Dynamic Menu using different ZK Components

Part 1: This article will explain how we can use ZK Menu Component to build N level of menu dynamically
Part 2: This article will explain how to create Tree type Menu dynamically.
Part 3: This article will explain how to create Left Navigation Menu Using group Box and Tool Bar Button
Part 4: This article will explain how to create top level navigation menu with two levels dynamically.
Part 5:  This article will explain how to create 4 Level of Menu for an Web app application

You can see the online demo here and download the source code.

ZK Dynamic Menu Part 5

In Part 3, we have seen how to create left navigation menu using ZK Group Box and ZK Tool bar button dynamically and also in part 4, Using the same data set, We created two level menu in the top using Tab box and Tool bar as like this ZK Demo.

Now we will combine Part 3 and Part 4, i.e we will create 4 level menu, 1st level in Tabbox , 2nd Second Tab Panel Tool Bar Button, 3nd Level Left Group Box and 4th Level Tool Bar Button under each group Box.

MenuItem.java

package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItem {
private String name;
private List<MenuItem> children;
private int level;

public MenuItem(String name,int level) {
this.name = name;
this.level = level;
children = new ArrayList<MenuItem>();
}

public void addChild(MenuItem node) {
children.add(node);
}

public void appendChild(MenuItem child) {
if (children == null)
children = new ArrayList<MenuItem>();
children.add(child);
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public List<MenuItem> getChildren() {
return children;
}

public void setChildren(List<MenuItem> children) {
this.children = children;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

}


MenuItemData.java


package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItemData {

private static List<MenuItem> menus = new ArrayList<MenuItem>();
static {

MenuItem m1 = new MenuItem("Administration",1);
MenuItem m1_lv1 = new MenuItem("Security",2);
MenuItem m1_Lv2 = new MenuItem("Accounts",3);

MenuItem m1_Lv3 = new MenuItem("User",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Role",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("User Rights",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Role Rights",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Regional",3);
m1_Lv3 = new MenuItem("Clock",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Language",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Keyboard",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Devices",3);
m1_Lv3 = new MenuItem("Printer",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Projector",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Mouse",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("Network",2);
m1_Lv2 = new MenuItem("Wireless",3);
m1_Lv3 = new MenuItem("Connection 1",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Connection 2",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Adapter",3);
m1_Lv3 = new MenuItem("Local Area Connection",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Virtual Box Network",4);
m1_Lv2.addChild(m1_Lv3);

m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("My Computer",2);
m1_Lv2 = new MenuItem("Drives",3);
m1_Lv3 = new MenuItem("C Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("D Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("E Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Favorites",3);
m1_Lv3 = new MenuItem("Desktop",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Downloads",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Recent Places",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Google Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);
m1.addChild(m1_lv1);
menus.add(m1);

/************************************************************************/
m1 = new MenuItem("ZK",1);
m1_lv1 = new MenuItem("Products",2);
m1_Lv2 = new MenuItem("ZK SpreadSheet",3);

m1_Lv3 = new MenuItem("3D Cell",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Freeze rows",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Ranged Cells",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ZK Pivottable",3);
m1_Lv3 = new MenuItem("Drill Down",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Render",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Paging",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ZK Calender",3);
m1_Lv3 = new MenuItem("Views",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Drag and Drop",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Time Zones",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ZK Spring",3);
m1_Lv3 = new MenuItem("HTTP Request",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("HTTP Basic",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("MD4 Password",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("ZK Demo",2);
m1_Lv2 = new MenuItem("Grid",3);
m1_Lv3 = new MenuItem("Master Detail",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Data Binding",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Dynamic Data",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Data Filter",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ListBox",3);
m1_Lv3 = new MenuItem("Dual ListBox",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Paging",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Auto Sort",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("List Group",4);
m1_Lv2.addChild(m1_Lv3);

m1_Lv2 = new MenuItem("Effects",3);
m1_Lv3 = new MenuItem("jQuery Effects",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Upload Effect",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Login Effect",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Display Action",4);
m1_Lv2.addChild(m1_Lv3);


m1_Lv2 = new MenuItem("Layout",3);
m1_Lv3 = new MenuItem("Portal Layout",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Complex Border Layout",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Group Box",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Boxes",4);
m1_Lv2.addChild(m1_Lv3);


m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("ZK Support",2);
m1_Lv2 = new MenuItem("Documentation",3);
m1_Lv3 = new MenuItem("Spread Sheet",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("ZK Calender",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("ZK Studio",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Downloads",3);
m1_Lv3 = new MenuItem("ZK Spring",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("ZK JSP",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);
m1.addChild(m1_lv1);

menus.add(m1);
m1 = new MenuItem("Eclipse",1);
menus.add(m1);
m1_lv1 = new MenuItem("File",2);
m1_Lv2 = new MenuItem("Project",3);

m1_Lv3 = new MenuItem("New Maven",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("New JPA",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("New JEE",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);
m1.addChild(m1_lv1);
}

public static List<MenuItem> getAllMenus() {
return new ArrayList<MenuItem>(menus);
}

}


index.zul


<window title="Dynamic Menu Example !!" border="normal" height="98%"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.example.menu.MainMenuVM')">
<borderlayout>
<north id="north" border="0" height="9%" flex="true">
<div id="Menu" sclass="Mainmenudiv">
<tabbox>
<tabs children="@load(vm.menuItems)">
<template name="children" var="item">
<tab label="@load(item.name)" />
</template>
</tabs>
<tabpanels children="@load(vm.menuItems)">
<template name="children" var="item">
<tabpanel height="200px">
<toolbar
children="@load(item.children)">
<template name="children"
var="aa">
<toolbarbutton
onClick="@command('onMenuClick',item=aa)"
label="@load(aa.name)" />
</template>
</toolbar>
</tabpanel>
</template>
</tabpanels>
</tabbox>
</div>
</north>
<west size="20%" flex="true" maxsize="250" splittable="true"
collapsible="true">
<div >
<vlayout children="@load(vm.selectedMenuItem.children)">
<template name="children" var="item">
<groupbox width="250px" mold="3d"
sclass="leftnav">
<caption label="@load(item.name)" />
<vbox>
<toolbarbutton label="${each.name}"
forEach="${item.children}" />
</vbox>
</groupbox>
</template>
</vlayout>
</div>
</west>
<center border="none" flex="true">
<div style="background:#E6D92C">
<label value="" style="color:white;font-size:50px" />
</div>
</center>
</borderlayout>
</window>


MainMenuVM.java


package com.example.menu;

import java.util.List;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;

public class MainMenuVM {

private List<MenuItem> menuItems;
private MenuItem selectedMenuItem;


public MenuItem getSelectedMenuItem() {
return selectedMenuItem;
}

public void setSelectedMenuItem(MenuItem selectedMenuItem) {
this.selectedMenuItem = selectedMenuItem;
}

public List<MenuItem> getMenuItems() {
return menuItems;
}

public void setMenuItems(List<MenuItem> menuItems) {
this.menuItems = menuItems;
}

public MainMenuVM() {
menuItems = MenuItemData.getAllMenus();
setSelectedMenuItem(menuItems.get(0).getChildren().get(0));
}

@Command
@NotifyChange("selectedMenuItem")
public void onMenuClick(@BindingParam("item") MenuItem item) {
setSelectedMenuItem(item);
}
}

Output
image


Please check ZK 7 Project Start-up Kit – Dynamic Menu

ZK Dynamic Menu Part 4

In Part 3, we have seen how to create left navigation menu using ZK Group Box and ZK Tool bar button dynamically. Using the same data set, We can also create two level menu in the top using Tab box and Tool bar as like this ZK Demo.


MenuItem.java

package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItem {
private String name;
private List<MenuItem> children;
private int level;

public MenuItem(String name,int level) {
this.name = name;
this.level = level;
children = new ArrayList<MenuItem>();
}

public void addChild(MenuItem node) {
children.add(node);
}

public void appendChild(MenuItem child) {
if (children == null)
children = new ArrayList<MenuItem>();
children.add(child);
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public List<MenuItem> getChildren() {
return children;
}

public void setChildren(List<MenuItem> children) {
this.children = children;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

}

MenuItemData.java


package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItemData {

private static List<MenuItem> menus = new ArrayList<MenuItem>();
static {

MenuItem m1_Lv1 = new MenuItem("ZK SpreadSheet",1);
MenuItem m1_Lv2 = new MenuItem("3D Cell",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Freeze rows",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Ranged Cells",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

m1_Lv1 = new MenuItem("ZK Pivottable",1);
m1_Lv2 = new MenuItem("Drill Down",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Render",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Paging",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

m1_Lv1 = new MenuItem("ZK Calender",1);
m1_Lv2 = new MenuItem("Views",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Drag and Drop",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Time Zones",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

m1_Lv1 = new MenuItem("ZK Spring",1);
m1_Lv2 = new MenuItem("HTTP Request",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("HTTP Basic",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("MD4 Password",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

}

public static List<MenuItem> getAllMenus() {
return new ArrayList<MenuItem>(menus);
}

}

index.zul


<div apply="org.zkoss.bind.BindComposer" width="600px"
viewModel="@id('vm') @init('com.example.menu.TabBoxVM')">
<tabbox>
<tabs children="@load(vm.menuItems)">
<template name="children" var="item">
<tab label="@load(item.name)" />
</template>
</tabs>
<tabpanels children="@load(vm.menuItems)">
<template name="children" var="item">
<tabpanel height="200px">
<toolbarbutton label="${each.name}"
forEach="${item.children}" />
</tabpanel>
</template>
</tabpanels>
</tabbox>

</div>


VM


package com.example.menu;

import java.util.List;

public class TabBoxVM {

private List<MenuItem> menuItems;

public List<MenuItem> getMenuItems() {
return menuItems;
}

public void setMenuItems(List<MenuItem> menuItems) {
this.menuItems = menuItems;
}

public TabBoxVM() {
menuItems = MenuItemData.getAllMenus();

}
}



 



Output
image



image


Please check ZK 7 Project Start-up Kit – Dynamic Menu

Sunday, 15 September 2013

ZK Dynamic Menu Part 3

In Part 2, we have seen how to Fill tree component dynamically. In this post, how we can create left navigation menu using ZK Group Box and ZK Tool bar button dynamically.
MenuItem.java
package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItem {
private String name;
private List<MenuItem> children;
private int level;

public MenuItem(String name,int level) {
this.name = name;
this.level = level;
children = new ArrayList<MenuItem>();
}

public void addChild(MenuItem node) {
children.add(node);
}

public void appendChild(MenuItem child) {
if (children == null)
children = new ArrayList<MenuItem>();
children.add(child);
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public List<MenuItem> getChildren() {
return children;
}

public void setChildren(List<MenuItem> children) {
this.children = children;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

}

MenuItemData.java


package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItemData {

private static List<MenuItem> menus = new ArrayList<MenuItem>();
static {

MenuItem m1_Lv1 = new MenuItem("ZK SpreadSheet",1);
MenuItem m1_Lv2 = new MenuItem("3D Cell",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Freeze rows",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Ranged Cells",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

m1_Lv1 = new MenuItem("ZK Pivottable",1);
m1_Lv2 = new MenuItem("Drill Down",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Render",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Paging",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

m1_Lv1 = new MenuItem("ZK Calender",1);
m1_Lv2 = new MenuItem("Views",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Drag and Drop",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("Time Zones",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

m1_Lv1 = new MenuItem("ZK Spring",1);
m1_Lv2 = new MenuItem("HTTP Request",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("HTTP Basic",2);
m1_Lv1.addChild(m1_Lv2);
m1_Lv2 = new MenuItem("MD4 Password",2);
m1_Lv1.addChild(m1_Lv2);
menus.add(m1_Lv1);

}

public static List<MenuItem> getAllMenus() {
return new ArrayList<MenuItem>(menus);
}

}


index.zul


<zk>
<style>
.leftnav .z-groupbox-3d-hm { background-image: none;
background-color: #0A246A !important; }

.leftnav .z-groupbox-3d-header .z-caption { color: yellow;
font-weight: bold;; } .leftnav .z-groupbox-3d-cnt {
background-image: none; background-color: #EAECF0 !important; }
</style>
<window border="normal" title="Menu" width="200px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.example.menu.GroupBoxVM')">
<vlayout vflex="min" children="@load(vm.menuItems)">
<template name="children" var="item">
<groupbox width="250px" mold="3d" sclass="leftnav">
<caption label="@load(item.name)" />
<vbox>
<toolbarbutton label="${each.name}"
forEach="${item.children}" />
</vbox>
</groupbox>
</template>
</vlayout>
</window>
</zk>



GroupBoxVM


package com.example.menu;

import java.util.List;

public class GroupBoxVM {

private List<MenuItem> menuItems;

public List<MenuItem> getMenuItems() {
return menuItems;
}

public void setMenuItems(List<MenuItem> menuItems) {
this.menuItems = menuItems;
}

public GroupBoxVM() {
menuItems = MenuItemData.getAllMenus();

}
}


Output:
image

Please check ZK 7 Project Start-up Kit – Dynamic Menu

ZK Dynamic Menu Part 2

In the last article, we have seen how we can dynamically create Menu using Menu component. In this post, we will see how we can create Dynamic tree using the same class.

MenuItem.java

package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItem {
private String name;
private List<MenuItem> children;
private int level;

public MenuItem(String name,int level) {
this.name = name;
this.level = level;
children = new ArrayList<MenuItem>();
}

public void addChild(MenuItem node) {
children.add(node);
}

public void appendChild(MenuItem child) {
if (children == null)
children = new ArrayList<MenuItem>();
children.add(child);
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public List<MenuItem> getChildren() {
return children;
}

public void setChildren(List<MenuItem> children) {
this.children = children;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

}


MenuItemData.java


package com.example.menu;

import java.util.ArrayList;
import java.util.List;

public class MenuItemData {

private static List<MenuItem> menus = new ArrayList<MenuItem>();
static {

MenuItem m1 = new MenuItem("Administration",1);
MenuItem m1_lv1 = new MenuItem("Security",2);
MenuItem m1_Lv2 = new MenuItem("Accounts",3);

MenuItem m1_Lv3 = new MenuItem("User",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Role",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("User Rights",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Role Rights",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Regional",3);
m1_Lv3 = new MenuItem("Clock",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Language",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Keyboard",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Devices",3);
m1_Lv3 = new MenuItem("Printer",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Projector",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Mouse",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("Network",2);
m1_Lv2 = new MenuItem("Wireless",3);
m1_Lv3 = new MenuItem("Connection 1",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Connection 2",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Adapter",3);
m1_Lv3 = new MenuItem("Local Area Connection",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Virtual Box Network",4);
m1_Lv2.addChild(m1_Lv3);

m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("My Computer",2);
m1_Lv2 = new MenuItem("Drives",3);
m1_Lv3 = new MenuItem("C Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("D Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("E Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Favorites",3);
m1_Lv3 = new MenuItem("Desktop",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Downloads",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Recent Places",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Google Drive",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);
m1.addChild(m1_lv1);
menus.add(m1);

/************************************************************************/
m1 = new MenuItem("ZK",1);
m1_lv1 = new MenuItem("Products",2);
m1_Lv2 = new MenuItem("ZK SpreadSheet",3);

m1_Lv3 = new MenuItem("3D Cell",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Freeze rows",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Ranged Cells",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ZK Pivottable",3);
m1_Lv3 = new MenuItem("Drill Down",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Render",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Paging",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ZK Calender",3);
m1_Lv3 = new MenuItem("Views",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Drag and Drop",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Time Zones",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ZK Spring",3);
m1_Lv3 = new MenuItem("HTTP Request",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("HTTP Basic",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("MD4 Password",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("ZK Demo",2);
m1_Lv2 = new MenuItem("Grid",3);
m1_Lv3 = new MenuItem("Master Detail",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Data Binding",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Dynamic Data",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Data Filter",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("ListBox",3);
m1_Lv3 = new MenuItem("Dual ListBox",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Paging",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Auto Sort",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("List Group",4);
m1_Lv2.addChild(m1_Lv3);

m1_Lv2 = new MenuItem("Effects",3);
m1_Lv3 = new MenuItem("jQuery Effects",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Upload Effect",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Login Effect",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Display Action",4);
m1_Lv2.addChild(m1_Lv3);


m1_Lv2 = new MenuItem("Layout",3);
m1_Lv3 = new MenuItem("Portal Layout",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Complex Border Layout",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Group Box",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("Boxes",4);
m1_Lv2.addChild(m1_Lv3);


m1_lv1.addChild(m1_Lv2);

m1.addChild(m1_lv1);

/***************************************************/
m1_lv1 = new MenuItem("ZK Support",2);
m1_Lv2 = new MenuItem("Documentation",3);
m1_Lv3 = new MenuItem("Spread Sheet",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("ZK Calender",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("ZK Studio",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);

m1_Lv2 = new MenuItem("Downloads",3);
m1_Lv3 = new MenuItem("ZK Spring",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("ZK JSP",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);
m1.addChild(m1_lv1);

menus.add(m1);
m1 = new MenuItem("Eclipse",1);
menus.add(m1);
m1_lv1 = new MenuItem("File",2);
m1_Lv2 = new MenuItem("Project",3);

m1_Lv3 = new MenuItem("New Maven",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("New JPA",4);
m1_Lv2.addChild(m1_Lv3);
m1_Lv3 = new MenuItem("New JEE",4);
m1_Lv2.addChild(m1_Lv3);
m1_lv1.addChild(m1_Lv2);
m1.addChild(m1_lv1);
}

public static List<MenuItem> getAllMenus() {
return new ArrayList<MenuItem>(menus);
}

}

MyTreeModel.java


package com.example.menu;

import org.zkoss.zul.AbstractTreeModel;
import org.zkoss.zul.ext.Selectable;

public class MyTreeModel extends AbstractTreeModel<Object> implements Selectable<Object>{

private static final long serialVersionUID = 1L;
private MenuItem _root;

public MyTreeModel(Object root) {
// set the root
super(root);
_root = (MenuItem) root;

}
@Override
public boolean isLeaf(Object node) {
return ((MenuItem) node).getChildren().size() == 0; // at most 4 levels
}

@Override
public Object getChild(Object parent, int index) {
return ((MenuItem) parent).getChildren().get(index);
}

@Override
public int getChildCount(Object parent) {
return ((MenuItem) parent).getChildren().size();
}


public boolean isMutiple()
{
return true;
}
}

index.zul


<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="mainmenubar" apply="org.zkoss.bind.BindComposer"
border="none" onCreate="@command('onFulfill')"
viewModel="@id('vm') @init('com.example.menu.TreeMenuVM')">
<tree model="@bind(vm.model)" id="mytree"
zclass="z-filetree" rows="22"
height="auto" >
<template name="model" var="node" status="s">
<treeitem open="true">
<treerow>
<treecell label="@bind(node.name)" />
</treerow>
</treeitem>
</template>
</tree>
</window>
</zk>






TreeMenuVM.java


package com.example.menu;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Tree;
import org.zkoss.zul.TreeModel;
import org.zkoss.zul.Treeitem;

public class TreeMenuVM {

@Wire("#mytree")
private Tree mytree;

TreeModel _model;
private List<MenuItem> allMenus;

public TreeModel getModel() {
if (_model == null) {
MyTreeModel a = new MyTreeModel(getRoot());
a.setMultiple(true);
_model = a;
}
return _model;
}

@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view) {
Selectors.wireComponents(view, this, false);
mytree.setFocus(true);
}

public MenuItem getRoot() {
MenuItem superRoot = new MenuItem("Menu", 0);
MenuItem root = new MenuItem("Menu", 0);
allMenus = MenuItemData.getAllMenus();
MenuItem m1 = allMenus.get(0);
MenuItem m2 = allMenus.get(1);
MenuItem m3 = allMenus.get(2);
superRoot.addChild(root);
root.addChild(m1);
root.addChild(m2);
root.addChild(m3);
return superRoot;
}

@Command
public void onFulfill() {
doCollapseExpandAll(mytree, true);
}

public static void doCollapseExpandAll(Component component,
boolean aufklappen) {
if (component instanceof Treeitem) {
Treeitem treeitem = (Treeitem) component;
treeitem.setOpen(aufklappen);
}
Collection<?> com = component.getChildren();
if (com != null) {
for (Iterator<?> iterator = com.iterator(); iterator.hasNext();) {
doCollapseExpandAll((Component) iterator.next(), aufklappen);

}
}
}

}


Output:
image

Please check ZK 7 Project Start-up Kit – Dynamic Menu