/**
 * Copyright (c) 2009 IBM Corporation
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *
 * $Id$
 */
package org.openhealthtools.mdht.uml.cda.ccd.tests;

import org.eclipse.emf.common.util.Diagnostic;
import org.openhealthtools.mdht.uml.cda.CDAFactory;
import org.openhealthtools.mdht.uml.cda.Section;
import org.openhealthtools.mdht.uml.cda.ccd.CCDFactory;
import org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument;
import org.openhealthtools.mdht.uml.cda.ccd.EpisodeObservation;
import org.openhealthtools.mdht.uml.cda.ccd.ProblemAct;
import org.openhealthtools.mdht.uml.cda.ccd.ProblemHealthStatus;
import org.openhealthtools.mdht.uml.cda.ccd.ProblemObservation;
import org.openhealthtools.mdht.uml.cda.ccd.ProblemStatus;
import org.openhealthtools.mdht.uml.cda.util.BasicValidationHandler;
import org.openhealthtools.mdht.uml.cda.util.CDAUtil;

public class Main {
	public static void main(String[] args) throws Exception {	
		ProblemAct problemAct = CCDFactory.eINSTANCE.createProblemAct().init();
		ProblemObservation problemObservation = CCDFactory.eINSTANCE.createProblemObservation().init();	
		ProblemStatus problemStatus = CCDFactory.eINSTANCE.createProblemStatus().init();
		ProblemHealthStatus problemHealthStatus = CCDFactory.eINSTANCE.createProblemHealthStatus().init();
		EpisodeObservation episodeObservation = CCDFactory.eINSTANCE.createEpisodeObservation().init();
		
		Section sect = CDAFactory.eINSTANCE.createSection();
		sect.addAct(problemAct);
		sect.addObservation(problemObservation);
		sect.addObservation(problemStatus);
		sect.addObservation(problemHealthStatus);
		sect.addObservation(episodeObservation);
		
		ContinuityOfCareDocument doc = CCDFactory.eINSTANCE.createContinuityOfCareDocument().init();
		doc.addSection(sect);

		CDAUtil.save(doc, System.out);
		
		CDAUtil.validate(doc, new BasicValidationHandler() {
			@Override
			public void handleError(Diagnostic diagnostic) {
				System.out.println("ERROR: " + diagnostic.getMessage());
			}
		});
	}
}

@@ -492,111 +492,8 @@
 c;%0D%0A
-import org.openhealthtools.mdht.uml.cda.CDAFactory;%0D%0Aimport org.openhealthtools.mdht.uml.cda.Section;%0D%0A
 impo
@@ -545,16 +545,16 @@
 ctory;%0D%0A
+
 import o
@@ -861,32 +861,93 @@
 emObservation;%0D%0A
+import org.openhealthtools.mdht.uml.cda.ccd.ProblemSection;%0D%0A
 import org.openh
@@ -1665,16 +1665,23 @@
 %0D%0A%09%09%0D%0A%09%09
+Problem
 Section 
@@ -1687,19 +1687,19 @@
  sect = 
+C
 CD
-A
 Factory.
@@ -1714,16 +1714,23 @@
 E.create
+Problem
 Section(
@@ -2221,16 +2221,16 @@
 tic) %7B%0D%0A
-
 %09%09%09%09Syst
@@ -2289,16 +2289,288 @@
 %0D%0A%09%09%09%7D%0D%0A
+%09%09%09@Override%0D%0A%09%09%09public void handleWarning(Diagnostic diagnostic) %7B%0D%0A%09%09%09%09System.out.println(%22WARNING: %22 + diagnostic.getMessage());%0D%0A%09%09%09%7D%0D%0A%09%09%09@Override%0D%0A%09%09%09public void handleInfo(Diagnostic diagnostic) %7B%0D%0A%09%09%09%09System.out.println(%22INFO: %22 + diagnostic.getMessage());%0D%0A%09%09%09%7D%0D%0A
 %09%09%7D);%0D%0A%09

update for ProblemSection