Advertisement
nikosv

HL7 Gazelle Validation

Jul 26th, 2016
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.24 KB | None | 0 0
  1. #Calling Gazelle HL7 v2.x validation web service
  2. #Nikos Vaggalis
  3. #http://www.i-programmer.info/programming/perl/9920-health-level-7-hl7-with-perl.html
  4. #license:Artistic 1.0
  5. use XML::Compile::SOAP::Trace;
  6. use XML::Compile::WSDL11;
  7. use XML::Compile::SOAP11;
  8. use XML::Compile::Transport::SOAPHTTP;
  9. use XML::Compile::SOAP::Trace ;
  10. use XML::LibXML;
  11. use strict;
  12.  
  13. my $wsdl = XML::Compile::WSDL11->new("gazelleHL7v2ValidationWS.wsdl");
  14.    $wsdl->importDefinitions("ValidationContext.xsd");
  15. my $message='MSH|^~\&|Sending Application|Sending Facility|Receiving Application|Receiving Facility|20160712125216+0200||ADT^A01^ADT_A01|id201|P|2.5|||||||||||
  16. EVN||20060501140008|||000338475^Author^Arthur^^^^^|20160711
  17. PID|||100660325^^^NationalPN&2.16.840.1.113883.19.3&ISO^0~80253^^^XXX^^1||GREENING^WAYNE^^^^^L||19610130|M|||||||||||||||LONDON|
  18. PV1||E|||||12345678901|||||||||||0||0|
  19. DG1|1||S42.1|||A|
  20. DG1|2||S42.2|||A|';
  21.  
  22. my $validate=
  23.  
  24. { # sequence of choice, ValidationOptions, CharacterEncoding
  25.  
  26.   # choice of ProfileOID, Profile
  27.  
  28.   # is a xs:string
  29.   ProfileOID => "1.3.6.1.4.12559.11.1.1.60",
  30.  
  31.   # is an unnamed complex
  32.   # is optional
  33.   ValidationOptions =>
  34.   { # sequence of MessageStructure, Length, DataType, DataValue
  35.  
  36.     # is a xs:string
  37.     # defaults to 'ERROR'
  38.     # Enum: ERROR IGNORE WARNING
  39.     MessageStructure => "ERROR",
  40.  
  41.     # is a xs:string
  42.     # defaults to 'WARNING'
  43.     # Enum: ERROR IGNORE WARNING
  44.     Length => "WARNING",
  45.  
  46.     # is a xs:string
  47.     # defaults to 'ERROR'
  48.     # Enum: ERROR IGNORE WARNING
  49.     DataType => "ERROR",
  50.  
  51.     # is a xs:string
  52.     # defaults to 'WARNING'
  53.     # Enum: ERROR IGNORE WARNING
  54.     DataValue => "WARNING", },
  55.  
  56.   # is a xs:string
  57.   # is optional
  58.   CharacterEncoding => "UTF-8",
  59.  
  60. };
  61.  
  62. my $schema = XML::Compile::Schema->new("ValidationContext.xsd");
  63. my $doc    = XML::LibXML::Document->new('1.0', 'UTF-8');
  64. my $write  = $schema->compile(WRITER =>'ValidationContext');
  65. my $xml    = $write->($doc, $validate);
  66.    
  67.    $doc->setDocumentElement($xml);
  68.  
  69.    my $finalstuct ={
  70.             xmlValidationMetadata=>'',
  71.             xmlValidationContext=>"$doc",
  72.             messageToValidate=>$message
  73.         };
  74. my $call = $wsdl->compileClient('validateMessage');
  75.  
  76. my ($response, $trace) = $call->($final,'UTF-8');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement