Skip Navigation Links | |
Exit Print View | |
![]() |
Oracle Java CAPS Adapter for TCP/IP HL7 Tutorial Java CAPS Documentation |
TCP/IP HL7 Adapter Inbound and Outbound Tutorial
Standard Inbound and Outbound Samples
Working With the Standard Inbound and Outbound Sample Projects (V2.x)
Installing the TCP/IP HL7 Adapter and Sample Projects
Installing the TCP/IP HL7 Adapter
Installing the TCP/IP Adapter in the NetBeans IDE
Downloading the Sample Projects
Importing the Sample TCP/IP HL7 Adapter Projects
Importing the TCP/IP Adapter Sample Projects
Checking Out the Imported Projects
Creating and Configuring the Environments
Creating and Configuring the HL7 Outbound Environment
Creating Environments for the HL7 Inbound and Outbound Samples
Configuring the Connectivity Map Properties
To Configure the Connectivity Map Properties
Creating the Deployment Profile
To Create the Deployment Profile
Creating Deployment Profiles for the HL7 Inbound and Outbound Samples
Building and Deploying the Project
Working With the Schematron HL7 V3 Sample Project
Modifying the Connectivity Map
To Modify the Connectivity Map
Modifying the Java Collaboration Definition
Modify the Collaboration Editor
Schematron Validation Inside the JCD
Excerpt for Beginning Schematron Validation
validateWithSchematron() method
Retrieving the Validation Results
Creating and Importing Sample Files
Importing a Schematron XML File
Building and Deploying the Sample Project
This sample project receives an HL7 V3 message, PRPA_IN403001UV01, and sends an HL7 V3 ACK or NAK, MCCI_IN000004UV01. This project is same as prjHL7V3Inbound except for the schematron validation for the input XML.
Follow these steps in the order given to complete the schematron sample:
In order to work with the sample project, you need to download it from the Repository using the Suite Uploader and then import it using NetBeans.
Before You Begin
Make sure the required Message Libraries are installed. In addition to the HL7 OTD Library and HL7 OTD Generic Library, which are installed with the TCP/IP HL7 Adapter by default, you need to install the following two libraries:
HL7V32006PatientAdmin.sar
HL7V32006TransInfra.sar
A confirmation dialog box appears asking if you need to save any changes.
The Import Manager appears.
Note - A warning message appears if you already have a project of the same name in the CAPS Repository. Determine whether you want to overwrite the existing project. In some cases the imported file will add files to an existing project. If you do not want to overwrite the existing project, cancel the import and exit the Import Manager. Rename and save the existing project, and attempt the import again.
It may take a few seconds to import the project. When the project is imported, the Import Status dialog box appears.
The CAPS Repository is refreshed.
You should now have two new projects in the tree structure of the Projects window.
Note - In the current example, the JAR file (checkprofileid.jar) is bundled along with the sample project file imported from Java CAPS Repository, prjHL7V3Inbound_WithSchematron.
When you first import a project, all of its components are checked in to version control. This means you cannot edit the project. You need to check the components out first.
The Connectivity Map appears in the Connectivity Map Editor.
The Properties Editor appears.
Enable Schematron Validation: true
Schematron Files: Provide a list of Schematron files. Use a comma to separate multiple files.
The JCD is edited as described in the steps below.
The Collaboration appears in the Java Collaboration Editor.
The following sections describe parts of the JCD that define schematron validation.
The schematron validation API is invoked from the JCD. The JCD follows the standard HL7 V3 validation; the schematron validation API is only invoked if the Enable Schematron Validation property is true. Following is an excerpt from the JCD code that scans the schematron files list and calls the method validateWithSchematron() if schematron validation is enabled.
boolean validated = validateHL7Message( HL7message ); java.util.ArrayList outputList = new java.util.ArrayList(); if (validated) { boolean schematronValidationEnabled = input.getHL7v3MessageInfo().getSchematronValidationInfo(). isSchematronValidationEnabled(); log( LOG_LEVEL_INFO, "SchematronEnabled = " + schematronValidationEnabled ); if (schematronValidationEnabled) { String[] schFiles = input.getHL7v3MessageInfo().getSchematronValidationInfo(). getSchematronFilesList(); log( LOG_LEVEL_INFO, "schFilesList = " + schFiles ); for (int i = 0; i < schFiles.length; i++) { log( LOG_LEVEL_INFO, "Adding schematron file for validation = " + schFiles[i] ); com.stc.connector.hl7.schematron.ValidationOutput output = validateWithSchematron( "/" + schFiles[i], HL7message ); outputList.add( output ); } for (int i = 0; i < outputList.size(); i++) { com.stc.connector.hl7.schematron.ValidationOutput output = (com.stc.connector.hl7.schematron.ValidationOutput) outputList.get( i ); if (!output.isValid()) { validated = false; schematronValidationError = true; log( LOG_LEVEL_INFO, "Schematron Validation failed." ); break; } else { validated = true; } }
The above text has been wrapped for display purposes. The images below show the code as it appears in the Collaboration Editor.
The schematron method invokes the schematron API. It reads the schematron files from classpath and constructs a DOM source. The DOM source passes it to obtain the SchematronValidator object. The object invokes the validate() method to pass the hl7payload. The following excerpt from the JCD defines the validation method.
private com.stc.connector.hl7.schematron.ValidationOutput validateWithSchematron( String schematronFile, byte[] hl7payload ) throws Exception { com.stc.connector.hl7.schematron.SchematronValidatorFactory factory =com.stc.connector.hl7.schematron.SchematronValidatorFactory. getSchematronValidatorFactory(); log( LOG_LEVEL_INFO, "Schematron URI :" + this.getClass().getResource( schematronFile ).toString() ); java.io.InputStream in = this.getClass().getResourceAsStream( schematronFile ); java.io.BufferedReader bufReader = new java.io. BufferedReader( new java.io.InputStreamReader( in ) ); StringBuffer schematronXml = new StringBuffer(); String line = bufReader.readLine(); while (line != null) { schematronXml.append( line ); line = bufReader.readLine(); } bufReader.close(); javax.xml.parsers.DocumentBuilderFactory domBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); domBuilderFactory.setNamespaceAware( true ); org.w3c.dom.Document doc = domBuilderFactory.newDocumentBuilder(). parse( new org.xml.sax.InputSource( new java.io.ByteArrayInputStream (schematronXml.toString().getBytes() ) ) ); javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource( doc.getDocumentElement() ); com.stc.connector.hl7.schematron.SchematronValidator validator = factory.getDefaultValidator( domSource ); javax.xml.transform.stream.StreamSource dataSrc = new javax.xml. transform.stream.StreamSource(new java.io.ByteArrayInputStream( hl7payload ) ); com.stc.connector.hl7.schematron.ValidationOutput output = validator.validate( dataSrc ); return output; }
The above text has been wrapped for display purposes. The images below show the code as it appears in the Collaboration Editor.
The makeNAK() method retrieves the XML document generated from the schematron validation. The XML document is embedded in the AcknowledgementDetail section of HL7V3 Acknowledgement XML. The following excerpt defines the makeNAK() method.
makeNAK() method
if (schematronValidationError) { log( LOG_LEVEL_INFO, "Schematron validationOutputList.size=" + validationOutputList.size()); for (int i = 0; i < validationOutputList.size(); i++) { com.stc.connector.hl7.schematron.ValidationOutput output = (com.stc.connector.hl7.schematron.ValidationOutput) validationOutputList.get( i ); String outputStr = output.getOutputAsString(); otd_MCCI_IN000004UV01_1.getAcknowledgement( 0 ). getAcknowledgementDetail( i ).getTypeCode().setCode( "E" ); otd_MCCI_IN000004UV01_1.getAcknowledgement( 0 ). getAcknowledgementDetail( i ).getCode().setCode ( "Validation Failure: Schematron Validation Failed" ); otd_MCCI_IN000004UV01_1.getAcknowledgement( 0 ). getAcknowledgementDetail( i ).getText().setMediaType( "text/xml" ); otd_MCCI_IN000004UV01_1.getAcknowledgement( 0 ). getAcknowledgementDetail( i ).getText().setX__PCDATA__MX( outputStr ); log( LOG_LEVEL_INFO, "Schematron Validation Output = " + outputStr ); } }
The above text has been wrapped for display purposes. The image below shows the code as it appears in the Collaboration Editor.
This section provides sample schematron validation and input files, and also gives instructions on importing the validation file for use in the JCD.
Below is a sample schematron validation file that checks for the presence of the profileid field in the PRPA_IN403001UV01 OTD.
<?xml version="1.0" encoding="UTF-8"?> <sch:schema xmlns:sch="http://www.ascc.net/xml/schematron"> <sch:ns prefix="hl7v3" uri="urn:hl7-org:v3"/> <sch:pattern name="Check structure"> <sch:rule context="hl7v3:PRPA_IN403001UV01"> <sch:assert test="count(hl7v3:profileId) = 1">The profileId should be present. It is missing.</sch:assert> </sch:rule> </sch:pattern> </sch:schema>
<PRPA_IN403001UV01 xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 PRPA_IN403001UV01.xsd"> <id root="1.1.2.3.4.6" extension="5929" assigningAuthorityName="Litware Inc."/> <creationTime value="20050303180027"/> <versionCode code="V3PR1"/> <interactionId root="1.1.6.7.8" extension="PRPA_IN403001UV01" assigningAuthorityName="HL7"/> <profileId root="1.1.1.1"/> <processingCode code="D"/> <processingModeCode code="T"/> <acceptAckCode code="AL"/> ... ... ...
Note - The above text has been wrapped for display purposes. It contains extra line breaks.
This tutorial includes a JAR file, checkprofileid.jar. which includes the sample schematron validation file described above. Follow this procedure if you want to create your own validation file and package it for the JCD.
The file now appears in the Projects window beneath the schematron project.
Follow the steps below to create an Environment for the cmHL7V3Inbound Connectivity Map in the schematron sample project.
A new environment is created and is added to the CAPS Environment tree.
It takes few seconds to process the Logical Host into the Environment.
A new application server (SunJavaSystemApplicationServer1) is added to the Environment under LogicalHost1.
A new JMS IQ Manager (SunJmsIQMgr1) is added to the Environment tree under LogicalHost1.
The External System is added to the Environment tree.
The new External System is added to the Environment tree.
Once you create the Environment, you need to create a Deployment Profile in order to build and deploy the project.
The Deployment Profile Editor appears.
The Automap Results dialog box appears.
To run data through the sample project, you need to use an HL7 simulator or HL7 application.
<?xml version="1.0" encoding="UTF-8"?> <PRPA_IN403001UV01 xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 PRPA_IN403001UV01.xsd"> <id root="1.1.2.3.4.6" extension="5929" assigningAuthorityName="Litware Inc."/> <creationTime value="20050303180027"/> <versionCode code="V3PR1"/> <interactionId root="1.1.6.7.8" extension="PRPA_IN403001UV01" assigningAuthorityName="HL7"/> <!--profileId root="1.1.1.1"/--> <processingCode code="D"/> <processingModeCode code="T"/> <acceptAckCode code="AL"/> <receiver typeCode="RCV"> <device classCode="DEV" determinerCode="INSTANCE"> <id root="1.4.7.8.3"/> </device> </receiver> <sender typeCode="SND"> <device classCode="DEV" determinerCode="INSTANCE"> <id root="1.45.6.7.98"/> </device> </sender> <controlActProcess classCode="CACT" moodCode="EVN"> <subject typeCode="SUBJ" contextConductionInd="false"> <encounterEvent classCode="ENC" moodCode="EVN"> <id root="1.56.3.4.7.5" extension="122345" assigningAuthorityName="Maple Hospital Emergency"/> <code code="EMER" codeSystem="2.16.840.1.113883.5.4"/> <statusCode code="active"/> <subject contextControlCode="OP"> <patient classCode="PAT"> <id root="1.56.3.4.7.9" extension="55321" assigningAuthorityName="Maple Hospital Patients"/> <patientPerson classCode="PSN" determinerCode="INSTANCE"> <name> <given>Rob</given> <given>P</given> <family>Young</family> </name> <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/> <birthTime value="19800309"/> </patientPerson> </patient> </subject> </encounterEvent> </subject> </controlActProcess> </PRPA_IN403001UV01>
The above text has been wrapped to fit the page. The following image shows the text in an XML editor.
Drivename:\JavaCAPS6U1\appserver\domains\domian1\logs
This action displays the following message.
Schematron Validation Failed