Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Each country has their own implementation of the National Connector and therefore the way that OpenNCP connects with the NC will be different for each country. Therefore it is necessary to “inject” country-specific functionality implementations into the Protocol Terminator.

...

Here is an example that shows the ServiceLoader in action.  Here you can see how an implementation of the PatientSearchInterface is loaded. 

Code Block
languagejava
linenumberstrue
public class XCPDServiceImpl implements XCPDServiceInterface {
    private ServiceLoader<PatientSearchInterface> serviceLoader;
    private PatientSearchInterface patientSearchService;
    
    public XCPDServiceImpl() {
        serviceLoader = ServiceLoader.load(PatientSearchInterface.class);
    	try {
    		logger.info("Loading National implementation of PatientSearchInterface...");
    		patientSearchService = serviceLoader.iterator().next();
    		logger.info("Successfully loaded PatientSearchService");
    	} catch (ServiceConfigurationError e) {
    		logger.fatal("Exception loading PatientSearchService: ", e);
    	}
    }
}

...

Mock implementations of the DocumentSubmitImpl, DocumentSearchImpl and PatientSearchImpl are provided in the project epsos-ws-serverproject epsos-nc-mock-implit (integration test, not Italy!).  These classes simply return dummy responses (not implemented yet)or exceptions where appropriate.  Please refer to the /wiki/spaces/INT/pages/4948035 Wiki pages for more information.  The mock implementations are packaged as a jar file epsos-ws-serverfile epsos-nc-mock-impl-0.1.0it.jar.

Image RemovedImage Added

Packaging

Each country must build their own jar file containing their own implementations, dependencies and supporting files.This National jar file

can be bundled into the There are a number of strategies for building the OpenNCP Server and bundling in the National jar, for example:

  1. Build epsos-ws-server.war in a local build environment using maven profile "national-connector-impl" to include the local classes as a dependency.  The disadvantage with this approach is that the local build server must download all the source files from Google Code repository plus all dependencies from Joinup.
  2. Download a released epsos-ws-server.war

...

  1. from Joinup.  Use a local build script to unpack the archive, bundle in the local classes and then repackage.  This is the preferred approach in Sweden.
  2. Download epsos-ws-server.war from Joinup.  Add local classes to tomcat/lib.  This has been briefly tested and did not work due to class loader errors.  Furthermore it is never a good idea to deploy application-specific classes into tomcat/lib.

Local build using profile

Here are the profiles that are declared in the Protocol Terminator pom file.

Code Block
languagehtml/xml
	<profiles>
		<profile>
			<!-- This profile bundles a mock National Connector interfaceimplementation -->
			<id>national-connector-mock-impl</id>
			<dependencies>
				<dependency>
					<groupId>eu.epsos.protocolterminators.ws.server</groupId>
					<artifactId>epsos-ws-server-mock-impl</artifactId>
					<version>0.1.0</version>
					<scope>runtime</scope>
				                    <groupId>eu.europa.ec.joinup.ecc.epsos-protocol-terminators.epsos-ncp-server</groupId>
                    <artifactId>epsos-nc-mock-it</artifactId>
                    <version>0.1-SNAPSHOT</version>
                    <scope>runtime</scope>
                </dependency>
			</dependencies>
		</profile>
		<profile>
			<!-- This profile bundles the country-specifigreal National Connector interfaceimplementation -->
			<id>national-connector-impl</id>
			<dependencies>
				<dependency>
					<groupId>${national-connector-impl.groupId}</groupId>
					<artifactId>${national-connector-impl.artifactId}</artifactId>
					<version>${national-connector-impl.version}</version>
					<scope>runtime</scope>
				</dependency>
			</dependencies>
		</profile>
	</profiles>

The first profile bundles the a mock implementations implementation into the war file.  The second profile bundles a National implementation.  If no profile is specified then no implementation will be bundled at all.  In this case, the jar must be deployed to the tomcat/lib directory.The National profile needs some properties.  These properties are defined

To use the National profile some properties must be set in the local build environment.  There are a few options for doing this:

Per User

- Defined in the Maven-settings (%USER_HOME%/.m2/settings.xml).

...

Code Block
languagehtml/xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <id>national-connector-impl</id>
      <properties>
        <national-connector-impl.groupId>se.apotekensservice</national-connector-impl.groupId>
        <national-connector-impl.artifactId>epsos-shelob</national-connector-impl.artifactId>
        <national-connector-impl.version>0.0.1-SNAPSHOT<version>1.1</national-connector-impl.version>
      </properties>
    </profile>
  </profiles>
</settings>

Here are the Maven commands for activating the various profiles:

Code Block
languagenone
# build epsos-ws-serverwith no implementation
mvn clean install
 
# build epsos-ws-server with mock implementations
mvn clean install -P national-connector-mock-impl
 
# build epsos-ws-server with real implementations
mvn clean install -P national-connector-impl

...

Manipulation of epsos-ws-server.war

Here is the Maven pom that Sweden uses to download OpenNCP from Joinup Nexus repository and then bundle in the jar containing the National implementations.

Code Block
languagehtml/xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>epsos</artifactId>
		<groupId>se.apotekensservice</groupId>
		<version>1.0-SNAPSHOT<1</version>
	</parent>
	<groupId>se.apotekensservice</groupId>
	<artifactId>epsos-ncp<<artifactId>epsos-ws-server</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<name>Package OpenNCP<<name>OpenNCP Server (Country A)</name>
	<description>This project fetchesdownloads the OpenNCP epsos-ws-server.war. and Itbundles then unpacks it, adds in the shelob.jar dependency and creates a new web archive<National implementations</description>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependencywar-plugin</artifactId>
				<version>2.5.1<3</version>
				<executions><configuration>
					<execution><packagingExcludes>**/epsos*-mock-*.jar</packagingExcludes>
						<id>unpack<</id>configuration>
						<phase>package</phase></plugin>
						<goals>
							<goal>unpack</goal>
					</plugins>
	</goals>build>
						<configuration><dependencies>
							<artifactItems><dependency>
								<artifactItem>
									<groupId>${project.openNcpGroupId}<<groupId>se.apotekensservice</groupId>
									<artifactId>${project.openNcpArtifactId}<<artifactId>epsos-shelob</artifactId>
									<version>${project.openNcpVersion}<<version>1.1</version>
									<type>war</type></dependency>
									<overWrite>true</overWrite><dependency>
									<outputDirectory>${project.build.directory}/epsos-ws-server</outputDirectory>
									<includes></includes>
									<excludes>epsos-ws-server-mock*.jar</excludes>
								</artifactItem>
							</artifactItems>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>${project.shelobGroupId}</groupId>
			<artifactId>${project.shelobArtifactId}</artifactId>
			<version>${project.shelobVersion}</version>
		</dependency>
		<dependency>
			<groupId>${project.openNcpGroupId}</groupId>
			<artifactId>${project.openNcpArtifactId}</artifactId>
			<version>${project.openNcpVersion}</version>
			<type>war</type>
		</dependency>
	</dependencies>
	<properties>
		<!-- OpenNCP war -->
		<project.openNcpGroupId>eu.europa.ec.joinup.ecc.epsos-protocol-terminators.epsos-ncp-server</project.openNcpGroupId>
		<project.openNcpArtifactId>epsos-ws-server</project.openNcpArtifactId>
		<project.openNcpVersion>0.2.1-SNAPSHOT</project.openNcpVersion>
		<!-- Shelob jar -->
		<project.shelobGroupId>se.apotekensservice</project.shelobGroupId>
		<project.shelobArtifactId>epsos-shelob</project.shelobArtifactId>
		<project.shelobVersion>0.0.1-SNAPSHOT</project.shelobVersion>
	</properties>
</project><groupId>eu.europa.ec.joinup.ecc.epsos-protocol-terminators.epsos-ncp-server</groupId>
			<artifactId>epsos-ws-server</artifactId>
			<version>2.0.0-SNAPSHOT</version>
			<type>war</type>
		</dependency>
	</dependencies>
</project>

XCPD PatientSearchInterface usage

TODO

XCA DocumentSearchInterface usage

Interfaces

The current implementation of the interface is as follows:

Code Block
languagejava
public interface DocumentSearchInterface extends NationalConnectorInterface {
   public DocumentAssociation<PSDocumentMetaData> getPSDocumentList(SearchCriteria searchCriteria);
   public List<DocumentAssociation<EPDocumentMetaData>> getEPDocumentList(SearchCriteria searchCriteria);
   public EPSOSDocument getDocument(SearchCriteria searchCriteria);
}
The DocumentAssociation interface
Code Block
languagejava
public interface DocumentAssociation<T extends EPSOSDocumentMetaData> {
   public T getXMLDocumentMetaData();
   public T getPDFDocumentMetaData();
   public String getDocumentClassCode(String documentId);
   public String getPatientId(String documentId);
}

The DocumentAssociation will store XML and PDF document metadata and has two helper methods for searching document's classCode and patientId.

The EPSOSDocumentMetaData
Code Block
languagejava
public interface EPSOSDocumentMetaData {
   public String getId();
   public String getPatientId();
   public int getFormat();
   public Date getEffectiveTime();
   public String getClassCode();
   public String getRepositoryId();
   public String getTitle();
   public String getAuthor();
}

This interface is a parent for EPDocumentMetaData and PSDocumentMetaData that reprecent the EPrescription and PatientSummary metaDatas.

The EPSOSDocument
Code Block
languagejava
public interface EPSOSDocument {
	public String getPatientId();
	public String getClassCode();
	public org.w3c.dom.Document getDocument();
	public boolean matchesCriteria(SearchCriteria sc);
}

The EPSOSDocument has the actual DOM document plus a subset of the metadata. The interface also has a helper method for checking that if the SearchCriteria matches the metadata.

The SearchCriteria
Code Block
languagejava
public interface SearchCriteria {
 public enum Criteria {
    PatientId,
    RepositoryId,
    DocumentId
 }
   public SearchCriteria add(Criteria c, String value);
   public String getCriteriaValue(Criteria c);
   public Iterator<Criteria> getSearchCriteriaKeys();
}
The SearchCriteria interface reprecents the criteria what will be used for searching the metaData and DOM documents from the national side. Currently the possible criteria values are in the Criteria enum.

Implementation

From the national component side

From the national component the usage of this interface, when returning DocumentAssociations should be something like:

Code Block
languagejava
EPDocumentMetaData epdXml = DocumentFactory.createEPDocumentXML(documentId, patientId, effectiveDate, repositoryId, title, author);
EPDocumentMetaData epdPdf = DocumentFactory.createEPDocumentPDF(documentId, patientId, effectiveDate, repositoryId, title, author);
DocumentFactory.createDocumentAssociation(epdXml, epdPdf);

PSDocumentMetaData psdPdf = DocumentFactory.createPSDocumentPDF(documentId, patientId, effectiveDate, repositoryId, title, author);
PSDocumentMetaData psdXml = DocumentFactory.createPSDocumentXML(documentId, patientId, effectiveDate, repositoryId, title, author);
DocumentFactory.createDocumentAssociation(psdPdf, psdXml);

And when returning the (DOM) document itself, should be implemented for example like:

Code Block
languagejava
EPSOSDocument epsosDocument = DocumentFactory.createEPSOSDocument(
		patientId,
		Constants.EP_CLASSCODE,
		xmlDocument);
From the XCAService component side

From the XCAService component side the usage of this interface is as following

Code Block
languagejava
//when fetching PatientSummary document metadatas:
DocumentAssociation<PSDocumentMetaData> daPs = documentSearchService.getPSDocumentList(DocumentFactory.createSearchCriteria().add(Criteria.PatientId, "patientId"));


//when fetching EPrescriptions metadatas:
List<DocumentAssociation<EPDocumentMetaData>> prescriptions = documentSearchService.getEPDocumentList(DocumentFactory.createSearchCriteria().add(Criteria.PatientId, "patientId"));


//when fetching the actual DOM document with metada:
EPSOSDocument epsosDoc = documentSearchService.getDocument(DocumentFactory.createSearchCriteria().add(Criteria.DocumentId, "documentId").add(Criteria.PatientId, "patientId").add(Criteria.RepositoryId,  "repositoryId"));

XDR DocumentSubmitInterface usage

TODO

References

Java SE6 ServiceLoader

...