Hospital based emergency departments (EDs) are highly integrated service units devoted primarily to handling the needs of patients arriving without prior appointment, and with uncertain conditions. In this context, analysis and management of patient flows play a key role in developing policies and decisions for overall performance improvement. However, patient flows in EDs are considered to be very complex because of the different pathways patients may take and the inherent uncertainty and variability of healthcare processes. The agent-based model provides a flexible platform for studying ED operations, as it predicts the system-level behavior from individual level interactions. In this way, policies such as staffing can be changed and the effect on system performance, such as waiting times and throughput, can be quantified. The overall goal of this study is to develop tools to better understand the complexity, evaluate policy and improve efficiencies of ED units. The main contribution of this paper includes: an agent-based model of ED, a flexible atomic data monitoring layer for agent state tracing, and a master/worker based framework for efficiently executing the model and analyzing simulation data. The presented model has been calibrated to imitate a real ED in Spain, the simulation results have proven the feasibility of using agent-based model to study ED system. In summary, starting from simulating the EDs, our efforts proved the feasibility and ideality of using agent based modeling and simulation techniques to study healthcare systems. The cross-validation results showed that the developed ED simulator can accurately represent the emergent behavior of the complex ED system. The framework developed in our work is a step towards building a full model of an integrated care system. It opens a wide field of possible simulation scenarios for a better understanding of the integrated complex system With the amount of adjustable parameters, the simulator is customizable to simulate a variety of scenarios. For example, the presented simulator is currently working as a platform to study MRSA transmission in EDs and as an experimental ED platform to provide data under various scenarios for knowledge discovery.