Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Calling Gazelle HL7 v2.x validation web service
- #Nikos Vaggalis
- #http://www.i-programmer.info/programming/perl/9920-health-level-7-hl7-with-perl.html
- #license:Artistic 1.0
- use XML::Compile::SOAP::Trace;
- use XML::Compile::WSDL11;
- use XML::Compile::SOAP11;
- use XML::Compile::Transport::SOAPHTTP;
- use XML::Compile::SOAP::Trace ;
- use XML::LibXML;
- use strict;
- my $wsdl = XML::Compile::WSDL11->new("gazelleHL7v2ValidationWS.wsdl");
- $wsdl->importDefinitions("ValidationContext.xsd");
- my $message='MSH|^~\&|Sending Application|Sending Facility|Receiving Application|Receiving Facility|20160712125216+0200||ADT^A01^ADT_A01|id201|P|2.5|||||||||||
- EVN||20060501140008|||000338475^Author^Arthur^^^^^|20160711
- PID|||100660325^^^NationalPN&2.16.840.1.113883.19.3&ISO^0~80253^^^XXX^^1||GREENING^WAYNE^^^^^L||19610130|M|||||||||||||||LONDON|
- PV1||E|||||12345678901|||||||||||0||0|
- DG1|1||S42.1|||A|
- DG1|2||S42.2|||A|';
- my $validate=
- { # sequence of choice, ValidationOptions, CharacterEncoding
- # choice of ProfileOID, Profile
- # is a xs:string
- ProfileOID => "1.3.6.1.4.12559.11.1.1.60",
- # is an unnamed complex
- # is optional
- ValidationOptions =>
- { # sequence of MessageStructure, Length, DataType, DataValue
- # is a xs:string
- # defaults to 'ERROR'
- # Enum: ERROR IGNORE WARNING
- MessageStructure => "ERROR",
- # is a xs:string
- # defaults to 'WARNING'
- # Enum: ERROR IGNORE WARNING
- Length => "WARNING",
- # is a xs:string
- # defaults to 'ERROR'
- # Enum: ERROR IGNORE WARNING
- DataType => "ERROR",
- # is a xs:string
- # defaults to 'WARNING'
- # Enum: ERROR IGNORE WARNING
- DataValue => "WARNING", },
- # is a xs:string
- # is optional
- CharacterEncoding => "UTF-8",
- };
- my $schema = XML::Compile::Schema->new("ValidationContext.xsd");
- my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
- my $write = $schema->compile(WRITER =>'ValidationContext');
- my $xml = $write->($doc, $validate);
- $doc->setDocumentElement($xml);
- my $finalstuct ={
- xmlValidationMetadata=>'',
- xmlValidationContext=>"$doc",
- messageToValidate=>$message
- };
- my $call = $wsdl->compileClient('validateMessage');
- my ($response, $trace) = $call->($final,'UTF-8');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement