Monday, 27 January 2014

How to process Co pay, Co Insurance and Deductible Amount in Insurance Payment Posting

Let us first see what is Co-pay, Co insurance and Deductible

Co-payment

A co-payment, or co-pay, is the flat amount you pay at the time of a medical service or to receive a medication. All insurance companies provide these costs to you up front. Insurance companies use these co-pays in part to share expenses with you.

Co-pay example: A doctor’s office visit might have a co-pay of $30. The co-pay for an emergency room visit will usually cost more, such as $150. However, there is a maximum amount you will pay for coinsurance and co-pays. This is called the coinsurance and co-pay maximum.


Coinsurance

Coinsurance and co-payments are not the same thing. A co-payment is a specific amount that you pay to the provider before you meet your deductible. Coinsurance is a percentage of a provider’s charge that you may be required to pay after you’ve met the deductible.

Example of coinsurance: Say you’ve already paid out (or met) your $147 Medicare deductible and your coinsurance is 20 percent. For a $100 health care bill, you would pay $20 and your insurance company would pay $80.

When you’ve met your deductible, you’ll have to pay coinsurance (Medicare is set to 20 % of the provider’s charge) until you reach your out-of-pocket maximum. After that, the insurance company will pay for all covered services to the policy maximum for the remainder of the year


Deductible

A deductible is the amount you pay for health care services before your health insurance begins to pay. For Medicare, this resets every year on January 1st.
Part B Deductible for 2014: $147 per year (for most people).


Difference Between Co-pay and Coinsurance

Coinsurance: Coinsurance is a term used for a percentage amount you are responsible for. For example if your insurance policy is 80/20, then the insurance is 80%. You are responsible for paying 20% of your bill. The 20% that you owe is called "coinsurance." This amount can vary as the cost of the services performed varies.

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.



While doing insurance Posting in PMS Software, line item may contain Co pay, Co Insurance and Deductible. The following are guidelines to handle the same.

PR - 1 Deductible Amount

Description:

In insurance policy terms, a deductible is the amount of money which the insured party must pay before the insurance company's own coverage plan begins. In practical terms, insurance companies include a deductible in their policies to avoid paying out benefits on relatively small claims.

Action:

1. We need to bill the patient.

2. If the patient has another insurance coverage which covers deductible we can file to that insurance, if the policy not cover primary deductibles we have no other way rather than billing the patient.

Claim processed as PR - 2 Coinsurance Amount

PR - 2 Coinsurance Amount

Coinsurance amounts are generally 20% of the Medicare fee schedule. Physicians must collect the unmet coinsurance from the beneficiary. Consistently waiving the coinsurance may be interpreted as program abuse. If a beneficiary is unable to pay the coinsurance, the physician should ask him or to sign a waiver that explains the financial hardship. If no waiver is signed, the beneficiary’s medical record should reflect normal and reasonable attempts to collect, before the charge is written off.

Action :

1. We need to file the claim to secondary insurance

2. If there is no secondary insurance we can bill the patient

EOB - PR - 3 Co-payment Amount

PR - 3 Co-payment Amounts

Description:

Co-payment A specified dollar amount or percentage of the charge identified that is paid by a beneficiary at the time of service to a health care plan, physician, hospital, or other provider of care for covered service provided to the beneficiary.

Cost sharing the general set of financial arrangements whereby the consumer must pay out-of-pocket to receive care, either at the time of initiating care, or during the provision of health care services, or both. Cost sharing can also occur when an insured pays a portion of the monthly premium for heath care insurance.

Action:

1. We need to bill the patient.

2. If there is any other insurance coverage if the patient has, we can bill to that insurance also.


  Co-pay Work Flow

  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.



  Deductible Workflow

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.





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

EMR SOAP Notes

Usually patient Medical record refers to SOAP Notes or patient encounter or Patient visit record. We will see the components of the SOAP Note here.

A SOAP note is a documentation method employed by health care providers to create a patient’s chart.  There are four parts of a SOAP note: ‘Subjective, Objective, Assessment, and Plan.

1. SUBJECTIVE

The initial portion of the SOAP note format consists of subjective observations. These are symptoms the patient verbally expresses or as stated by a significant other. These subjective observations include the patient's descriptions of pain or discomfort, the presence of nausea or dizziness, when the problem first started, and a multitude of other descriptions of dysfunction, discomfort, or illness the patient describes. To put simple, this section to record the reason why the patient came to meet the physician.

The following sections will be covered under the Subjective.

  • Chief Complaints
  • Family History
  • Social History includes Smoking , alcohol and Drug history.
  • Problem List (Current Problems)
  • Past Medical History
  • Past Surgical History
  • Current Medication History
  • Allergy
  • Review of Systems (ROS)
  • Birth History

2. Objective

Documents objective, repeatable, and traceable facts about the patient’s status.These objective observations include symptoms that can actually be measured, seen, heard, touched, felt, or smelled. Included in objective observations are vital signs such as temperature, pulse, respiration, skin color, swelling and the results of diagnostic tests.

The following sections will be covered under the Subjective.

  • Vital Signs and measurements, such as weight, height, etc.
  • Physical Examination
  • Results from Laboratory and other Diagnostic tests already completed.

3. Assessment

A medical diagnosis for the purpose of the medical visit on the given date of the note written is a quick summary of the patient with main symptoms/diagnosis including a differential diagnosis, a list of other possible diagnoses usually in order of most likely to least likely. It is the patient's progress since the last visit, and overall progress towards the patient's goal from the physician's perspective. When used in a Problem Oriented Medical Record, relevant problem numbers or headings are included as subheadings in the assessment.


4. Plan

This is what the health care provider will do to treat the patient's concerns - such as ordering further labs, radiological work up, referrals given, procedures performed, medications given and education provided. This should address each item of the differential diagnosis. A note of what was discussed or advised with the patient as well as timings for further review or follow-up are generally included.
Often the Assessment and Plan sections are grouped together.

The following sections will be covered under the Subjective.

  • Prescription
  • Order Lab Test
  • Refer to other Doctor
  • Instruction and Plan for the patient
  • Patient Education

Wednesday, 22 January 2014

HL7 OBX - observation/result segment

The OBX segment is used to transmit a single observation

OBX Segment Structure

Sno Element Name Len Data type Usage Table
1 ID 4 SI O
2 Value Type 2 ID C 0125
3 Observation Identifier 250 CE R
4 Observation Sub ID 20 ST O
5 Observation Value 65536 C
6 Units 250 CE R
7 Reference Ranges 60 ST R
8 Abnormal Flag 5 IS R 0078
9 Probability 5 NM O  
10 Nature of Abnormal Test 2 ID O 0080
11 Observation Result Status 1 ID R 0085
12 Date Last Observation 26 TS O
13 User defined Access Checks 20 ST O
14 Date/Time of Observation 26 TS O
15 Producer ID 250 CE O
16 Responsible Observer 250 XCN O
17 Observation Method 250 CE O
18 Equipment Instance Identifier 22 EI O
19 Date/Time of the Analysis 26 TS O  


Usage Description:

R Required
RE Required but may be Empty
O Optional
C Conditional
CE Conditional but it may be empty
x Not Supported




OBX.1 – ID (SI)

This field contains the sequence number.

Examples:

OBX|1|NM|NA^Sodium^LA01^2951-2^Sodium^LN||140|mmol/L|135-146|N|||F||N|200807170527||RECHELTJ

image

OBX.2 – Value Type (ID)

This field contains the format of the observation value in OBX. Most Commonly Used values are

CE Coded Element
NM Numeric
SN Structured Numeric
ST String Data
TX Text Data
FT Formatted text

The Complete valid values for the value type of an observation are listed in HL7 Table 0125  as follows
Value Description
AD Address
CE Coded Entry
CF Coded Element With Formatted Values
CK Composite ID With Check Digit
CN Composite ID And Name
CP Composite Price
CX Extended Composite ID With Check Digit
DT Date
ED Encapsulated Data
FT Formatted Text (Display)
MO Money
NM Numeric
PN Person Name
RP Reference Pointer
SN Structured Numeric
ST String Data.
TM Time
TN Telephone Number
TS Time Stamp (Date & Time)
TX Text Data (Display)
XAD Extended Address
XCN Extended Composite Name And Number For Persons
XON Extended Composite Name And Number For Organizations
XPN Extended Person Number
XTN Extended Telecommunications Number
RP Reference pointer is used to Point to Image if the observation value is image. 

Examples:

OBX|1|TX|OXY^OXID|  ^F^D|-9.99|200 ug/ml|0.0-200||||F||2|201309250911||RBJ||
OBX|2|TX|2589M^KRATUM|  ^D^E|||-||||N||4|201309240000||...||
OBX|3|ST|GLYCOHEM^Hemoglob A1C^LA01^4548-4^Hemoglob A1C^LN||6.8|% of total Hgb||H|||F|||200806250452||IF
OBX|4|NM|PT^Prothrombin Time^LA01^5902-2^Prothrombin Time^LN||12.1|seconds|11.8-14.3|N|||F||N|200806260829||IF
OBX|5|NM|1000714^TROPONIN I||0.0|NG/ML|0.0-0.2||||F|||20080628023100
OBX|6|ST|90020090^B MICRO DESCRIPTION^^90020090^B MICRO DESCRIPTION^||DNR||||||X|||20050923130500|CA^^L|||



OBX.3 - Observation identifier (CE)


This field contains a unique identifier for the observation (i.e., the individual test for which the result is reported in this OBX segment). The format is that of the Coded Element (CE). Example: 8625-6^P-R interval^LN.

The LOINC coding system must be used to represent the observation (test) identifier for results reported. HL7 permits senders to include both the Universal LOINC code and the local code for a given observation.For easy understanding, here we display the universal code in red and the local code in Blue as follows:
Please remember it is not necessary that LOINC Code should come first and followed by Local Code. Some lab will send in the reverse order.
LOINC Code^Print Text^LN^Local Code^Print Text^L

Element Format

CE Components: <identifier (ST)> ^ <text (ST)> ^ <name of coding system (IS)> ^ <alternate identifier (ST)> ^ <alternate text
(ST)> ^ <name of alternate coding system (IS)>

Please remember that not all the Lab system transmit the LOINC Code for the test observed. They may just use the internal Test code (alternate code) to represent the test.

Component Usage
identifier (ST) R
text (ST) R
name of coding system (IS) R
alternate identifier (ST) RE
alternate text (ST) RE
name of alternate coding system (IS) RE

Examples:

2089-1^LDL Cholesterol^LN^576X^LDL Chol^L

[LOINC code for LDL Cholesterol, plus a lab-specific code]

7564ZZ^Hep B SAg^L

Lab-specific code for Hep B surface antigen, coded per lab’s
proprietary coding system; note that Hep.

CL^Chloride^LA01^2075-0^Chloride^LN
The above example, local code appear first and LOINC Code appear second (2075-0 IS LOINC Code for Chloride)

The following example contain only Local Code representation
OBX|1|NM|164858^Antinuclear Antibodies Direct^L||22|AU/mL|0-99|||N|F|20041222||200807311545|CB



OBX-8 Abnormal flags (IS)

We can extract the abnormal flag from this field i.e status of the result. The valid values are as follows

Value Description
L Below Low Normal
H Above High Normal
LL Below lower panic limits
HH Above upper panic limits
< Below absolute low-off instrument scale
> Above absolute high-off instrument scale
N Normal (applies to non-numeric results)
A Abnormal (applies to non-numeric results)
AA

Very abnormal (applies to non-numeric units, analogous to panic limits for numeric
units)

U Significant change up
D Significant change down
B Better--use when direction not relevant
W Worse--use when direction not relevant
S Susceptible. Indicates for microbiology susceptibilities only.
R Resistant. Indicates for microbiology susceptibilities only.
I Intermediate. Indicates for microbiology susceptibilities only.
MS Moderately susceptible. Indicates for microbiology susceptibilities only.
VS

Very susceptible. Indicates for microbiology susceptibilities only


Examples:

OBX|2|NM|35005420^PROTHROMBIN TIME^^35005420^PROTHROMBIN TIME^||23.8|Seconds||H|||F|||20090615165900|MH^^L|||
 
image

 



OBX-11 Observation Result Status (ID)
This field contains the observation result status. Refer to HL7 table 0085 as follows

Value Description
C Record coming over is a correction and thus replaces a final result
D Deletes the OBX record
F Final results; Can only be changed with a corrected result.
I Specimen in lab; results pending
P Preliminary results
R Results entered -- not verified
S Partial results
X Results cannot be obtained for this observation
U

Results status change to Final. without retransmitting results already sent as ‘preliminary.’ E.g., radiology changes status from preliminary to final

W Post original as wrong, e.g., transmitted for wrong patient


Examples:

OBX|10|NM|BCR^BUN / Creat Ratio^LA01^3097-3^BUN / Creat Ratio^LN||8||||||F||N|200807170527||RECHELTJ 

image


Complete OBX Segment Examples:

OBX|1|NM|NA^Sodium^LA01^2951-2^Sodium^LN||140|mmol/L|135-146|N|||F||N|200807170527||RECHELTJ
OBX|2|NM|K^Potassium^LA01^2823-3^Potassium^LN||5.8|mmol/L|3.5-5.3|H|||F||N|200807170527||RECHELTJ
OBX|3|NM|CL^Chloride^LA01^2075-0^Chloride^LN||101|mmol/L|98-110|N|||F||N|200807170527||RECHELTJ
OBX|4|NM|CO2^CO2^LA01^2028-9^CO2^LN||23|mmol/L|21-33|N|||F||N|200807170527||RECHELTJ
OBX|5|NM|GAP^Anion Gap^LA01^X330373^Anion Gap^LN||16|mmol/L|3-16|N|||F||N|200807170527||RECHELTJ
OBX|6|NM|BUN^BUN^LA01^3094-0^BUN^LN||52|mg/dL|7-25|H|||F||N|200807170527||RECHELTJ
OBX|7|NM|CREAT^Creatinine^LA01^2160-0^Creatinine^LN||6.22|mg/dL|0.50-1.20|H|||F||N|200807170527||RECHELTJ
OBX|8|NM|GLU^Glucose^LA01^6777-7^Glucose^LN||101|mg/dL|65-99|H|||F||N|200807170527||RECHELTJ
OBX|9|NM|CA^Calcium^LA01^2000-8^Calcium^LN||7.2|mg/dL|8.6-10.2|L|||F||N|200807170527||RECHELTJ
OBX|10|NM|BCR^BUN / Creat Ratio^LA01^3097-3^BUN / Creat Ratio^LN||8||||||F||N|200807170527||RECHELTJ
OBX|11|NM|GFRAA^GFR MDRD Af Amer^LA01^X33914^GFR MDRD Af Amer^LN||8|See Note|||||F||N|200807170527||RECHELTJ



References:
1.
What are LOINC Codes ?
2. HL7 Data Types
3. Complete set of LOINC codes and associated documentation

How to create ZK Maven Project in Eclipse kepler


Step 1
Open Eclipse and go to Window –>Preferences –> Maven

image


Step 2:
Click Add Remote Catalog

image
Type catalog file as “http://mavensync.zkoss.org/maven2/

Step 3:
Click Verify. You will find some number of archetype(s)

image

Step : 4
Now select File –> New –> Other –> Maven Project

image

Step : 5

image
Just leave to default and select next


Step 6
Select ZK as catalog  and select 6.5.2

image

Step 7:
Enter group ID, artifactid and package as shown
image

Click Finish

Tuesday, 14 January 2014

Understanding EOB - Explanation of Benefits




Amount Billed

This represents the cost of the services and the amount Charged by the provider to the insurance company. i.e Amount Billed By the Provider for the service(Treatment) rendered. In Some Payer EOB, this also labelled as "Actual Amount Billed" or "Provider Charge" or "Amount Billed" or "Amount Charged" or "Charge" or "Charged Amount" or "Total Charges" or “Billed” .


Allowed Amount

Allowed amount reflects how much the Payer has decided to pay for the procedure or visit. Sometimes Payer will use the term “usual and customary charges” or another term in place of “allowed amount.”

Providers who have agreed to accept the insurance company’s allowed amount for visits and procedures are considered “in-network” providers. If you visited an in-network provider, you will not be charged the difference if the provider’s charge is higher than the allowed amount.

Some out-of-network providers do not agree to accept the insurance company’s allowed amount as full payment for a visit or service. If this is the case, you will likely be required to pay the difference between the doctor’s fee for a service and the allowed amount the insurance will pay. In some cases, the insurer does not provide any coverage for out-of-network care and you may find yourself paying the full charged price of the care you received.

Allowed Amount is usually determined by geographic location of provider.

In Some Payer EOB, this also labelled as "Amount Allowed" or "Payment Amount" or "Allowable Amount" or "Remaining Covered Charges" or "Contracted Amount" or " or “Allowed” .


Date of Service

The the actual date that the medical service/procedure was performed by the  Provider. This is NOT the date it was billed or processed.

In Some Payer EOB, it is also labelled as "DOS" or "Service Date"

HL7 Data types

Data types in HL7 Message

Group Data type Code Data Type Name
Alphanumeric    
ST String
TX Text Data
FT Formatted text
Numerical CQ Composite Quantity with Units
MO Money
NM Numeric
SI Sequence
SN Structured Number
Identifier
ID Coded values from HL7 Look up List
IS Coded values from user defined
HD Hierarchic designator
EI Entity identifier
RP Reference pointer
PL Person location
PT Processing type
Date and Time DT Date Only
TM Time Only
TS Time Stamp
Code Values CE Coded Element
CF Coded element with formatted values
TN Telephone Number
XAD Extended Address
XPN Extended Person Name
XON Extended composite name and ID number for organizations
XTN Extended telecommunications number
     



Examples :
1. Example for TS Date and Time data type in MSH Segment as follows
MSH|^~\&|aaa|My CLINICAL LAB|aaa|A232|201309050000||ORU^R01||P|2.3|

Format:
yyyyMMddHHmmss.SZ

Other Examples :
200202150930
20040822143045 [indicates date/time of Aug. 22, 2004 2:30 PM and 45 seconds]
20040822143045-0800 [indicates date/time of Aug. 22, 2004 2:30 PM and 45 seconds PST]

Monday, 13 January 2014

ZK MVVM Combo Box value Converter

Normally, Combo box will be loaded with the List of any objects and selected item will be bind into one of the property of the main class. Here is the typical example

Department.java (this will be shown as Drop down)

package zkexamples.mvvm;

public class Department {

private Long ID;
private String departmentName;

public Department(Long ID, String departmentName)
{
this.ID = ID;
this.departmentName = departmentName;
}
public Long getID() {
return ID;
}

public void setID(Long iD) {
ID = iD;
}

public String getDepartmentName() {
return departmentName;
}

public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}

}

Employer.java


package zkexamples.mvvm;

public class Employer {

private String code;
private String firstName;
private String lastName;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "departmentID")
private Department department;

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public Department getDepartment() {
return department;
}

public void setDepartment(Department department) {
this.department = department;
}



}


Here is the zul which shows the example


<?page title="Auto Generated index.zul"?>
<window title="Example for ZK MVVM Combo Box" width="800px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('zkexamples.mvvm.IndexVM')">
<label value="You are using: ${desktop.webApp.version}" />
<separator></separator>
<grid>
<columns>
<column width="10%"></column>
<column width="12%"></column>
<column width="16%"></column>
<column width="16%"></column>
</columns>
<rows>
<row>
<vlayout>
<label value="Code" />
<textbox id="code" hflex="1" name="code"
value="@bind(vm.employer.code)" maxlength="25" />
</vlayout>
<vlayout>
<label value="First Name" />
<textbox id="firstname" hflex="1" name="firstName"
value="@bind(vm.employer.firstName)" maxlength="100" />
</vlayout>
<vlayout>
<label value="Last Name" />
<textbox id="lastname" hflex="1" name="lastname"
value="@bind(vm.employer.lastName)" maxlength="100" />
</vlayout>

<vlayout>
<label value="Department" />
<combobox model="@load(vm.allDepartments)" hflex="1"
selectedItem="@bind(vm.employer.department)"
mold="rounded" autodrop="true" autocomplete="true">
<template name="model">
<comboitem
label="@load(each.departmentName)" value="@load(each.ID)" />
</template>
</combobox>
</vlayout>
</row>
</rows>
</grid>
<separator></separator>
<separator></separator>
<button label="Show Data" onClick="@command('saveThis')"></button>
</window>




But, for some reason, if we do not want to use ManytoOne or OneToMany fetch, and just we need the departmentID, then there is no simple way to do with ZK Combo. We need to write the converter.

Now let us modify the Employer class as follows


package zkexamples.mvvm;

public class Employer {

private String code;
private String firstName;
private String lastName;
private Long departmentID;

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public Long getDepartmentID() {
return departmentID;
}

public void setDepartmentID(Long departmentID) {
this.departmentID = departmentID;
}

}


Department.class remains the same, now let us modify the zul file


<?page title="Auto Generated index.zul"?>
<window title="Example for ZK MVVM Combo Box" width="800px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('zkexamples.mvvm.IndexVM')">
<label value="You are using: ${desktop.webApp.version}" />
<separator></separator>
<grid>
<columns>
<column width="10%"></column>
<column width="12%"></column>
<column width="16%"></column>
<column width="16%"></column>
</columns>
<rows>
<row>
<vlayout>
<label value="Code" />
<textbox id="code" hflex="1" name="code"
value="@bind(vm.employer.code)" maxlength="25" />
</vlayout>
<vlayout>
<label value="First Name" />
<textbox id="firstname" hflex="1" name="firstName"
value="@bind(vm.employer.firstName)" maxlength="100" />
</vlayout>
<vlayout>
<label value="Last Name" />
<textbox id="lastname" hflex="1" name="lastname"
value="@bind(vm.employer.lastName)" maxlength="100" />
</vlayout>

<vlayout>
<label value="Department" />
<combobox model="@load(vm.allDepartments)" hflex="1"
value="@bind(vm.employer.departmentID) @converter('zkexamples.mvvm.DepartmentConverter')"
mold="rounded" autodrop="true" autocomplete="true">
<template name="model">
<comboitem
label="@load(each.departmentName)" value="@load(each.ID)" />
</template>
</combobox>
</vlayout>
</row>
</rows>
</grid>
<separator></separator>
<separator></separator>
<button label="Show Data" onClick="@command('saveThis')"></button>
</window>


As you can see, we have the converter in the value property as follows

value="@bind(vm.employer.departmentID) @converter('zkexamples.mvvm.DepartmentConverter')"

Here is the converter code

package zkexamples.mvvm;

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

import org.zkoss.bind.BindContext;
import org.zkoss.bind.Converter;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Combobox;

public class DepartmentConverter implements Converter {

@SuppressWarnings({ "unchecked" })
public Object coerceToUi(Object val, Component comp, BindContext ctx) {
Combobox box;
box = (Combobox) comp;
if (box.getSelectedItem() == null) {
String departmentName = null;
if (val != null) {
List<Department> locationList = (List<Department>) box
.getModel();
for (Iterator<Department> i = locationList.iterator(); i
.hasNext();) {
Department tmp = i.next();
if (tmp.getID() == (Long) val) {
departmentName = tmp.getDepartmentName();
}
}
}
return departmentName;
} else
return box.getSelectedItem().getLabel();
}

public Object coerceToBean(Object val, Component comp, BindContext ctx) {

Combobox box;
box = (Combobox) comp;

if (box.getSelectedItem() == null)
return val;
else
return box.getSelectedItem().getValue();

}
}


Here viewModel


package zkexamples.mvvm;

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.zul.Messagebox;

public class IndexVM {

private List<Department> allDepartments;
private Employer employer = new Employer();

public Employer getEmployer() {
return employer;
}

public void setEmployer(Employer employer) {
this.employer = employer;
}

public List<Department> getAllDepartments() {
return allDepartments;
}

public void setAllDepartments(List<Department> allDepartments) {
this.allDepartments = allDepartments;
}

@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view) {
allDepartments = DemoData.getAllDepartment();
}

@Command
public void saveThis() {

String data = "";
data = "Code :" + this.employer.getCode() + " , " + "First Name :"
+ this.employer.getFirstName() + " , "
+ this.employer.getLastName() + " , " + " Department : "
+ this.employer.getDepartmentID();
Messagebox.show(data);
}
}


Now we will get the departmentID.

image

Refer the following ZK Forum also
http://forum.zkoss.org/question/79517/combobox-selecteditem-mvvm-databind-problem

http://forum.zkoss.org/question/86919/zk-mvvm-combox-box-data-binding/


http://forum.zkoss.org/question/61956/set-combobox-selected-item-by-value

Saturday, 11 January 2014

ZK MVVM List box with check box – Simple Example


ZK Version : ZK 7


Reference

Introduction of MVVM

List Box Template
ZK List box Documentation


Project Structure

image

index.zul

<window title="Example for ZK MVVM List Box" width="500px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('zkexamples.mvvm.ListBox2')">
<label value="You are using: ${desktop.webApp.version}" />
<separator></separator>
<listbox model="@load(vm.allPersons)" checkmark="true"
multiple="true" selectedItem="@bind(vm.selectedPerson)"
selectedItems="@bind(vm.selectedPersons)">
<listhead sizable="true">
<listheader label="First Name" sortDirection="ascending"
sort="auto(firstName)" />
<listheader label="Last Name" sort="auto(lastName)" />
<listheader label="Email" sort="auto(email)" />
</listhead>
<template name="model" var="p1">
<listitem>
<listcell label="@load(p1.firstName)" />
<listcell label="@load(p1.lastName)" />
<listcell label="@load(p1.email)" />
</listitem>
</template>
</listbox>
<button label="Show Selected Items email id"
onClick="@command('onShowEmailID')">
</button>
</window>



Listbox2.java


package zkexamples.mvvm;

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

import org.zkoss.bind.annotation.Command;
import org.zkoss.zul.Messagebox;

public class ListBox2 {

private List<person> allPersons = new ArrayList<person>();
private person selectedPerson;
private List<person> selectedPersons;

public person getSelectedPerson() {
return selectedPerson;
}

public void setSelectedPerson(person selectedPerson) {
this.selectedPerson = selectedPerson;
}

public List<person> getSelectedPersons() {
return selectedPersons;
}

public void setSelectedPersons(List<person> selectedPersons) {
this.selectedPersons = selectedPersons;
}

public List<person> getAllPersons() {
return allPersons;
}

public void setAllPersons(List<person> allPersons) {
this.allPersons = allPersons;
}

public ListBox2() {

allPersons.add(new person("John", "James", "JohnJames@yahoo.com"));
allPersons.add(new person("Taylor", "Harris", "Harris@yahoo.com"));
allPersons.add(new person("Allen", "Scott", "Scott@yahoo.com"));

}

@Command
public void onShowEmailID()
{
String emailIDs="";

if (this.selectedPersons==null)
{
Messagebox.show(" No Items selected");
return;
}

if (this.selectedPersons.size()==0)
{
Messagebox.show(" No Items selected");
return;
}

for (Iterator<person> i = selectedPersons.iterator(); i
.hasNext();) {
person tmp = i.next();
emailIDs = emailIDs.concat(tmp.getEmail()).concat(";");
}

Messagebox.show("Selected Emails are " + emailIDs);
}

// inner class
public class person {
private String firstName;
private String lastName;
private String email;

public person(String firstName, String lastName, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

}
}



Output:

image

Friday, 10 January 2014

ZK MVVM Simple List Box Example


ZK Version : ZK 7


Reference

Introduction of MVVM

List Box Template


Project Structure

image

Index.zul

<window title="Example for ZK MVVM List Box" width="500px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('zkexamples.mvvm.ListBox1')">
<label value="You are using: ${desktop.webApp.version}" />
<separator></separator>
<listbox model="@load(vm.allPersons)">
<listhead sizable="true">
<listheader label="First Name" sortDirection="ascending"
sort="auto(firstName)" />
<listheader label="Last Name" sort="auto(lastName)" />
<listheader label="Email" sort="auto(email)" />
</listhead>
<template name="model" var="p1">
<listitem>
<listcell label="@load(p1.firstName)" />
<listcell label="@load(p1.lastName)" />
<listcell label="@load(p1.email)" />
</listitem>
</template>
</listbox>
</window>


View Model

package zkexamples.mvvm;

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

public class ListBox1 {

private List<person> allPersons = new ArrayList<person>();

public List<person> getAllPersons() {
return allPersons;
}

public void setAllPersons(List<person> allPersons) {
this.allPersons = allPersons;
}

public ListBox1() {

allPersons.add(new person("John", "James", "JohnJames@yahoo.com"));
allPersons.add(new person("Taylor", "Harris", "Harris@yahoo.com"));
allPersons.add(new person("Allen", "Scott", "Scott@yahoo.com"));

}

// inner class
public class person {
private String firstName;
private String lastName;
private String email;

public person(String firstName, String lastName, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

}
}




Output

image

Wednesday, 8 January 2014

MSH - Message Header Segment

The MSH segment defines the intent, source, destination, and some specifics of the syntax of a message.

MSH Segment Structure

Sno Element Name Len Data type Usage Table
1 Field Separator 1 ST R
2 Encoding Characters 4 ST R  
3 Sending Application 180 HD X
4 Sending Facility 180 HD R
5 Receiving Application 180 HD X
6 Receiving Facility 180 HD X
7 Date/Time of Message 26 TS R
8 Security 40 ST X  
9 Message Type 13 CM R
10 Message Control ID 20 ST R  
11 Processing ID 3 PT R  
12 Version ID 60 VID R 0104
13 Sequence Number 60 NM X
14 Continuation Pointer 180 ST X
15 Accept Acknowledgement Type 2 ID R 0155
16 Application Acknowledgement Type 2 ID O 0155
17 Country Code 3 ID X
18 Character Set 16 ID X
19 Principal Language of Message 250 CE X
20 Alternate Character Set Handling Scheme 20 ID X 0211
21 Conformance Statement ID 30 ID R  

Usage Description:

R Required
RE Required but may be Empty
O Optional
C Conditional
CE Conditional but it may be empty
x Not Supported


MSH.1 – Field Separator

This field contains the separator between the segment. The recommended character is |, (ASCII 124).
Data type is ST – String

Examples:

MSH|^~\&|LAB|QTE||30218|20090714023209||ORU^R01|20090714235298399160|P|2.3|||||||


MSH.2 – Encoding Characters

This field contains the four characters in the following order: the component separator, repetition separator, escape character, and subcomponent separator. Recommended values are ^~\& (ASCII 94, 126, 92, and 38, respectively).

Segment Terminator <cr> Terminates a segment record. This value cannot be changed by implementers.
Field Separator | Separates two adjacent data fields within a segment. It also separates the segment ID from the first data field in each segment.
Component Separator ^ Separates adjacent components of data fields where allowed.
Subcomponent Separator & Separates adjacent subcomponents of data fields where allowed. If there are no subcomponents, this character may be omitted.
Repetition Separator ~ Separates multiple occurrences of a field where allowed.
Escape Character \ Escape character for use with any field represented by an ST, TX or FT data type, or for use with the data (fourth) component of the ED data type If no escape characters are used in a message, this character may be omitted. However, it must be present if subcomponents are used in the message.



MSH.3 – Sending Application
This field uniquely identifies the sending application among all other applications within the network enterprise. The network enterprise consists of all those applications that participate in the exchange of HL7 messages within the enterprise. Entirely site-defined.
Data type is HD

Components: <namespace ID (IS)> ^ <universal ID (ST)> ^ <universal ID type (ID)>

CL^57768-2
CP^387564

The value of <namespace ID> represents the high-level naming authority that controls the assignment of laboratory identifiers that appear in the <universal ID> component. The preferred naming authority is CLIA, and laboratories with a CLIA identifier must send that identifier in the <universal ID> component, along with the value “CL” in the <namespace ID> component

Examples:
MSH|^~\&|EPIC|EPICADT|SMS|SMSADT|199912271408|CHARRIS|ADT^A04|1817457|D|2.5|
MSH|^~\&|SHIEL|SHIEL|H_Dx|999994|200904100656||ORU^R01|SH13857997|D|2.3|
MSH|^~\&|ELYSIUMCONNECT|THA-I||TUH|20080722001201||ORU^R01|22001202527|P|2.2



MSH.4 – Sending Facility

This field uniquely identifies the receiving application among all other applications within the network enterprise. The network enterprise consists of all those applications that participate in the exchange of HL7 messages within the enterprise. Entirely site-defined.
Data type is HD.

Components: <namespace ID (IS)> ^ <universal ID (ST)> ^ <universal ID type (ID)>


MSH.5 – Receiving Application

This field identifies the receiving application among multiple identical instances of the application running on behalf of different organizations.
Entirely site-defined.
Data type is HD.


MSH Segment Examples:

MSH|^~\&|Test|My CLINICAL LAB|Test|100|201309050000||ORU^R01||P|2.3|

image