Requirement Constraints

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg
Showing posts with label Today Tech Stuff. Show all posts
Showing posts with label Today Tech Stuff. Show all posts

Friday, 9 August 2013

ZK upload PDF to server and show in the screen using MVVM

Posted on 03:42 by Unknown

Simple example to upload PDF file in the server and show the content using iframe.

<zk>
<window id="test" border="normal" height="98%"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('org.zk.example.FileUploadVM')">
<label value="You are using: ${desktop.webApp.version}" />
<separator></separator>
<label
value="Example for File upload to the server and display it" />
<separator></separator>
<hbox>
<label value="Upload any PDF File" />
<button label="Upload" upload="true"
onUpload="@command('onUploadPDF',upEvent=event)">
</button>
<button label="Show PDF" visible="@load(vm.fileuploaded)"
onClick="@command('showPDF')">
</button>
</hbox>

<iframe height="100%" width="100%" id="reportframe"
content="@bind(vm.fileContent)">
</iframe>
</window>




</zk>

ViewModel


package org.zk.example;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Calendar;

import org.zkoss.bind.BindContext;
import org.zkoss.bind.BindUtils;
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.bind.annotation.NotifyChange;
import org.zkoss.io.Files;
import org.zkoss.util.media.AMedia;
import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Iframe;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;

public class FileUploadVM {

private String filePath;
private boolean fileuploaded = false;
AMedia fileContent;

@Wire("#test")
private Window win;

public AMedia getFileContent() {
return fileContent;
}

public void setFileContent(AMedia fileContent) {
this.fileContent = fileContent;
}

public boolean isFileuploaded() {
return fileuploaded;
}

public void setFileuploaded(boolean fileuploaded) {
this.fileuploaded = fileuploaded;
}

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

}

@Command
@NotifyChange("fileuploaded")
public void onUploadPDF(
@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx)
throws IOException {

UploadEvent upEvent = null;
Object objUploadEvent = ctx.getTriggerEvent();
if (objUploadEvent != null && (objUploadEvent instanceof UploadEvent)) {
upEvent = (UploadEvent) objUploadEvent;
}
if (upEvent != null) {
Media media = upEvent.getMedia();
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH); // Note: zero based!
int day = now.get(Calendar.DAY_OF_MONTH);
filePath = Executions.getCurrent().getDesktop().getWebApp()
.getRealPath("/");
String yearPath = "\\" + "PDFs" + "\\" + year + "\\" + month + "\\"
+ day + "\\";
filePath = filePath + yearPath;
File baseDir = new File(filePath);
if (!baseDir.exists()) {
baseDir.mkdirs();
}

Files.copy(new File(filePath + media.getName()),
media.getStreamData());
Messagebox.show("File Sucessfully uploaded in the path [ ."
+ filePath + " ]");
fileuploaded = true;
filePath = filePath + media.getName();
}
}

@Command
@NotifyChange("fileContent")
public void showPDF() throws IOException {
File f = new File(filePath);
Messagebox.show(" dfdfdfdsfdsf" + filePath);
byte[] buffer = new byte[(int) f.length()];
FileInputStream fs = new FileInputStream(f);
fs.read(buffer);
fs.close();
ByteArrayInputStream is = new ByteArrayInputStream(buffer);
fileContent = new AMedia("report", "pdf", "application/pdf", is);



}
}
Read More
Posted in Today Tech Stuff, ZK Framework | No comments

Wednesday, 7 August 2013

ZK Quick InputBox

Posted on 19:55 by Unknown

Just to get String input before do some process. For example, we will normally ask the reason to delete any record.

<?xml version="1.0" encoding="UTF-8"?>
<zk>
<window id="inputstringbox" title="@load(vm.screenTitle)"
width="auto" height="auto" border="normal" minimizable="false"
sclass="mymodal" mode="modal" maximizable="false" closable="true"
action="hide: slideUp" apply="org.zkoss.bind.BindComposer"
onCancel="@command('closeThis')"
viewModel="@id('vm') @init('com.product.webapp.component.InputStringBoxVM')">
<ftextbox id="txtDescription" rows="4" cols="70"
value="@bind(vm.input)" />
<separator />
<div align="center">
<fbutton label="Ok" onClick="@command('onOk')" />
<fbutton label="Cancel" onClick="@command('closeThis')" />
</div>
</window>
</zk>

package com.product.webapp.component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.zkoss.bind.BindUtils;
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.bind.annotation.ExecutionArgParam;
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.Window;

import com.product.webapp.utilities.GlobalCommandValues;
import com.product.webapp.utilities.Libs;
import com.product.webapp.utilities.ShowWindow;
import com.product.webapp.utilities.ValidationMessage;

public class InputStringBoxVM {

@Wire("#inputstringbox")
private Window win;
private String input;
private String validateMessage;
private String screenTitle;

public String getInput() {
return input;
}

public String getScreenTitle() {
return screenTitle;
}

public void setScreenTitle(String screenTitle) {
this.screenTitle = screenTitle;
}

public String getValidateMessage() {
return validateMessage;
}

public void setValidateMessage(String validateMessage) {
this.validateMessage = validateMessage;
}

public void setInput(String input) {
this.input = input;
}

@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view,
@ExecutionArgParam("validateMessage") String validateMessage,
@ExecutionArgParam("screenTitle") String screenTitle) {
Selectors.wireComponents(view, this, false);
this.validateMessage = validateMessage;
this.screenTitle = screenTitle;
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@Command
public void onOk() {
if (IsValidEntry() == false) {
return;
} else {
Map args = new HashMap();
args.put("input", this.input);
BindUtils.postGlobalCommand(null, null,
GlobalCommandValues.InputStringEntered, args);
win.detach();
}
}

public boolean IsValidEntry() {

List<ValidationMessage> vList = new ArrayList<ValidationMessage>();

if (Libs.isNotEmpty(this.input) == false) {
vList.add(new ValidationMessage(this.validateMessage));
}

if (vList.size() > 0) {
ShowWindow.ShowValidation(vList);
return false;
} else
return true;
}

@Command
public void closeThis() {
win.detach();
}
}

public static void showInputBox(String title, String validateMessage,
Window callingFrom) {
final HashMap<String, Object> map = new HashMap<String, Object>();
map.put("screenTitle", title);
map.put("validateMessage", validateMessage);
if (callingFrom.hasFellow("inputstringbox") == false) {
Executions.createComponents("/ZK/components/inputstringbox.zul",
null, map);
}
}

@Command
public void onResetPassword() {
ShowWindow.showInputBox("Reason",
"Pleas Enter the reason to reset the password.", win);
}

@GlobalCommand(GlobalCommandValues.InputStringEntered)
public void resetPassword() {
// do something here
}
Read More
Posted in Today Tech Stuff, zk, ZK Framework | No comments

Friday, 2 August 2013

HL7 Parsing

Posted on 22:59 by Unknown

I was working in parsing the HL7 ORU Message using HAPI. Found an interesting article by here by Ignacio Suay. Thanks mate for simple and quick example

Based on that, here is my example, But still finding a way to extract OBR, OBX and NTE Segments.

package com.product.HL7;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.PipeParser;
import ca.uhn.hl7v2.util.Terser;
import ca.uhn.hl7v2.validation.impl.NoValidation;

import com.product.domain.LabResults;

public class ParseFile {

static final Logger LOG = LoggerFactory.getLogger(ParseFile.class);
private String HL7Message;
private List<HL7Data> MSH = new ArrayList<HL7Data>();
private List<HL7Data> orderInfo = new ArrayList<HL7Data>();
private ParsingEvent parseingEvent;

public List<HL7Data> getOrderInfo() {
return orderInfo;
}

public void setOrderInfo(List<HL7Data> orderInfo) {
this.orderInfo = orderInfo;
}

public ParseFile(ParsingEvent parseingEvent) {
this.parseingEvent = parseingEvent;
}

public String getHL7Message() {
return HL7Message;
}

public List<HL7Data> getMSH() {
return MSH;
}

public void setMSH(List<HL7Data> mSH) {
MSH = mSH;
}

public void setHL7Message(String hL7Message) {
HL7Message = hL7Message;
}

public void parseMessage() throws HL7Exception {

String element;
String value;
HapiContext context = new DefaultHapiContext();
context.setValidationContext(new NoValidation());
PipeParser pipeParser = context.getPipeParser();
/* pipeParser.setValidationContext(new NoValidation()); */
Message message = pipeParser.parse(HL7Message);
Terser terser = new Terser(message);

LabResults labResults = new LabResults();

element = "Receiving Facility";
value = terser.get("/.MSH-6");
LOG.debug(element + " : " + value);
labResults.setDocAccountNo(value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Date";
value = terser.get("/.MSH-7");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient No";
value = terser.get("/.PID-2");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Lab Accession Number";
value = terser.get("/.PID-4");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Last Name";
value = terser.get("/.PID-5-1");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient First Name";
value = terser.get("/.PID-5-2");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Middle Name";
value = terser.get("/.PID-5-3");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient DOB";
value = terser.get("/.PID-7");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Sex";
value = terser.get("/.PID-8");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Address";
value = terser.get("/.PID-11-1");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient City";
value = terser.get("/.PID-11-2");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient State";
value = terser.get("/.PID-11-3");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Zip";
value = terser.get("/.PID-11-4");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Phone";
value = terser.get("/.PID-13");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Maritial Status";
value = terser.get("/.PID-16");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient EHR Number";
value = terser.get("/.PID-18");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient SS";
value = terser.get("/.PID-19");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Care Number";
value = terser.get("/.PID-20");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Caid Number";
value = terser.get("/.PID-21");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Age";
value = terser.get("/.PID-23");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

/*********************** Order Informaton ************************************/

element = "Lab Accession Number";
value = terser.get("/.ORC-2");
LOG.debug(element + " : " + value);
orderInfo.add(new HL7Data(element, value));
value = null;
element = null;

parseingEvent.parsingCompleted();

}
}

Some important note.
1. Hapi always expect \r at the end of the each segment. So if you have manually append the character at the end of the each segment Smile as i did in my example

	// convert InputStream to String
private static String getStringFromInputStream(InputStream is) {

BufferedReader br = null;
StringBuilder sb = new StringBuilder();

String line;
try {

br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
sb.append(line + "\r");
}

} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

return sb.toString();

}


2. HAPI will also validate the Message while parsing. If you want to avoid that, see my example above.

3. But i don’t think so my job is going to easy to fetch OBR and OBX and NTE segments using HAPI. I am trying with that, latest will post if i am able to complete.

Sample File
MSH|^~\&|mas|My LAB|mas|3535|201305280003||ORU^R01||P|2.3|
PID|1|PAT393929|^^^MRN~^^^CID~^^^ACCN|000035100|MOOAFEFERE^SCOOPDSTT^||19690608|M|||^^FL^|||||U|||||||43|y|
ORC|1|000035100|||CM||||201302271648|PAH|201302271700|^^^^     ^^^^^|||||355^MY HOUSE|0011 NW 10 STR^MYCITY^NY^11111^111-371-1111|3|PAH|
OBR|1|000035100||BATH SALTS^BATH SALTS|||20130131----|201302271651||||||201302271648||^^^^     ^^^^^||D|DRUGS||||||F|
OBX|1|TX|BATH SALTS^BATH SALTS|  ^D^[|NEGATIVE||-||||F||7|201302271651||PAH||

Read More
Posted in EMR Labs Stuff, Today Tech Stuff | No comments

Wednesday, 22 September 2010

My Quick Reference

Posted on 01:02 by Unknown
Class with Static data which Returns as List

package demo.combobox.simple_combobox;

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

public class ShirtData {

private static List<String> colors = new ArrayList<String>();
private static List<String> sizes = new ArrayList<String>();

static{
colors.add("blue");
colors.add("black");
colors.add("white");

sizes.add("small");
sizes.add("medium");
sizes.add("large");
}

public static final List<String> getColors() {
return new ArrayList<String>(colors);
}

public static final List<String> getSizes() {
return new ArrayList<String>(sizes);
}
}





How to cast an Object to an int in java?

http://stackoverflow.com/questions/3661413/how-to-cast-an-object-to-an-int-in-java


If you're sure that this object is an Integer :

int i = (Integer) object;

Or, starting from Java 7, you can equivalently write:

int i = (int) object;

Beware, it can throw a ClassCastException if your object isn't an Integer and aNullPointerException if your object is null.

This way you assume that your Object is an Integer (the wrapped int) and you unbox it into an int.

int is a primitive so it can't be stored as an Object, the only way is to have an intconsidered/boxed as an Integer then stored as an Object.




If your object is a String, then you can use the Integer.valueOf() method to convert it into a simple int :

int i = Integer.valueOf((String) object);

It can throw a NumberFormatException if your object isn't really a String with an integer as content.








Java Inner class example




import java.util.*;

public class SampleVM {

private List<MyData> names = new ArrayList<MyData>();

public SampleVM() {
names.add(new MyData("name 1",true));
names.add(new MyData("name 2",false));
names.add(new MyData("name 3",false));
names.add(new MyData("name 4",false));
names.add(new MyData("name 5",false));


}


public List<MyData> getNames() {
return names;
}
public class MyData{
String name;
boolean open;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
public MyData(String name, boolean open) {
super();
this.name = name;
this.open = open;
}
}
}


 


Hibernate Where in clause to Delete multiple items

	@Override
public void deletePracticeAppMenu(List<Long> prAppMenuIDs, Long practiceID) {
String query = "delete from PracticeAppMenu where PrAppMenuID in (:appMenuIDs) and practiceID = :pracid ";
Query q = getCurrentSession().createQuery(query);
q.setParameterList("appMenuIDs", prAppMenuIDs);
q.setParameter("pracid", practiceID);
q.executeUpdate();
}

Read More
Posted in Today Tech Stuff | No comments
Home
Subscribe to: Posts (Atom)

Popular Posts

  • Understanding EDI Structure
    EDI Structure Primary Levels are 1. Interchange Envelops 2. Functional Group 3. Transaction set Data Element A data element is equival...
  • Types of Reimbursement
    Fee-For-Service Fee-for-service is a method of payment where the provider is paid a fee for each procedure performed and billed.Most payer ...
  • EDI 270–5010 Documentation - ISA – Interchange Control Header
    ISA – Interchange Control Header ISA – Interchange Control Header   The ISA is a fixed record length segment and all positions within ea...
  • EDI Instructions
    HIPAA Compliant Codes All the Health care EDI Transaction set should use only the following HIPAA Compliant Codes Physicians Current Pro...
  • ZK ListBox
    Let us first design a simple  static list box with crud Buttons as last column. Here is the code <?page title="Practice List" c...
  • ZK Example for inline Editing with Add New and Delete
    I am quite impressed on this demo from ZK . But adding new record and delete existing record is missing as part of typical CRUD. So i thoug...
  • Java Static Import
    This is one of feature in Java 5. In order to access static members, it is necessary to qualify references with the class they came from. ...
  • ZK MVVM CRUD With Spring 3 + JPA + Hibernate 4 Entity Manager–Part 3
    Define the persistence.xml file In the Part 2 article , we have seen how to create ZK Maven project and update the default POM.XML with a...
  • ZK MVVM Form Binding CRUD with Spring and Hibernate - Part 4
    Presentation Layer using ZK Framework          In part 3 , We have completed Spring integration with hibernate. In this post, we will des...
  • Hibernate–Java Environment setup
    Environment Eclipse 3.7 Indigo IDE Download Hibernate 4.1.1 Download JavaSE 1.6  Download MySQL 5.1 Download JDBC Driver for MyS...

Categories

  • Billing Process
  • C Workbook
  • C++ Workbook
  • Eclipse Tips
  • EDI 5010
  • EMR Appointment Features
  • EMR Labs Stuff
  • EMR PMS Links
  • EMR Use cases
  • EMR Vital Sign
  • Good Website Design
  • Hibernate Criteria Queries
  • Hibernate Introduction
  • Hibernate Introduction Setup
  • Hibernate Mapping
  • Hibernate POC
  • Hibernate Validator
  • Hibernate–Java Environment setup
  • HPI
  • Java
  • Maven
  • MU Certification
  • NPI
  • PQRS
  • Practice Management System
  • Spring Security
  • Tech Links
  • Today Tech Stuff
  • zk
  • ZK Hibernate
  • ZK 5 Databinding
  • ZK Application
  • ZK Calling Another ZUL
  • ZK CheckBox
  • ZK CreateComponents
  • ZK CSS
  • ZK extended Components
  • ZK Foreach
  • ZK Forum Posts
  • ZK Framework
  • ZK Hibernate Setup
  • ZK ID Space
  • ZK Include
  • ZK Installation
  • ZK iReport
  • ZK Layout
  • ZK Listitem Pagination
  • ZK Message Box
  • ZK MVC
  • ZK MVC Combox Box
  • ZK MVC CRUD Examples
  • ZK MVC Listbox
  • ZK MVVM
  • ZK MVVM Combo
  • ZK MVVM CRUD
  • ZK MVVM ListBox
  • ZK Spring
  • ZK TextBox

Blog Archive

  • ▼  2013 (105)
    • ▼  December (3)
      • EDI Instructions
      • Understanding EDI Structure
      • What is an EDI ?
    • ►  September (7)
    • ►  August (13)
    • ►  July (1)
    • ►  June (11)
    • ►  May (3)
    • ►  April (14)
    • ►  March (19)
    • ►  February (21)
    • ►  January (13)
  • ►  2012 (177)
    • ►  December (1)
    • ►  November (13)
    • ►  October (19)
    • ►  September (24)
    • ►  August (26)
    • ►  July (6)
    • ►  June (37)
    • ►  May (30)
    • ►  April (16)
    • ►  March (1)
    • ►  January (4)
  • ►  2011 (5)
    • ►  December (1)
    • ►  November (1)
    • ►  July (1)
    • ►  June (1)
    • ►  April (1)
  • ►  2010 (1)
    • ►  September (1)
Powered by Blogger.

About Me

Unknown
View my complete profile