| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | |||
| 4 | #---------------------------PERLDOC STARTS HERE------------------------------------------------------------------ | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | ws-sample | ||
| 9 | |||
| 10 | =cut | ||
| 11 | |||
| 12 | #--------------------------------------------------------------------------------------------------------------------- | ||
| 13 | |||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This a sample program which shows the flow of the complete package and how different modules interact with each other. | ||
| 18 | This program authenticates user by asking for valid username and password to connect to UMLSKS. Once the user is | ||
| 19 | authenticated program takes a term from the user and finds CUI using the UMLSKS Metathesaurus database. | ||
| 20 | The program queries SNOMED-CT database. | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | =head2 Basic Usuage | ||
| 27 | |||
| 28 | =pod | ||
| 29 | |||
| 30 | perl ws-sample.pl | ||
| 31 | |||
| 32 | Follwing is a sample output | ||
| 33 | |||
| 34 | =over | ||
| 35 | |||
| 36 | =item Enter username to connect to UMLSKS:mchoudhari | ||
| 37 | |||
| 38 | =item Enter password: | ||
| 39 | |||
| 40 | =item Enter query term : hair | ||
| 41 | |||
| 42 | =item CUI/s for term hair is : C0018494 | ||
| 43 | |||
| 44 | =back | ||
| 45 | |||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | #--------------------------------------------------------------------------------------------------------------------------- | ||
| 50 | |||
| 51 | #------------------------------PERLDOC ENDS HERE------------------------------------------------------------------------------ | ||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | #Program that connects to UMLSKS and queries the UMLS through the UMLSKS API to return information for an entered term or CUI. | ||
| 58 | |||
| 59 | # Author : Mugdha | ||
| 60 | # Reference: Program provided by Olivier B., NLM. | ||
| 61 | |||
| 62 | |||
| 63 | use strict; | ||
| 64 | use warnings; | ||
| 65 | use SOAP::Lite; | ||
| 66 | |||
| 67 | #use lib "/home/mugdha/UMLS-HSO/UMLS-HSO/WebService-UMLSKS-Similarity/lib"; | ||
| 68 | |||
| 69 | use WebService::UMLSKS::GetUserData; | ||
| 70 | use WebService::UMLSKS::ValidateTerm; | ||
| 71 | use WebService::UMLSKS::Query; | ||
| 72 | no warnings qw/redefine/; | ||
| 73 | |||
| 74 | |||
| 75 | my $verbose = 1; | ||
| 76 | |||
| 77 | # Creating object of class GetUserData and call the sub getUserDetails. | ||
| 78 | # Receive a $service object if the user is a valid user. | ||
| 79 | |||
| 80 | my $g = WebService::UMLSKS::GetUserData->new; | ||
| 81 | my $service = $g->getUserDetails($verbose); | ||
| 82 | |||
| 83 | if($service == 0){ | ||
| 84 | exit; | ||
| 85 | } | ||
| 86 | |||
| 87 | # Creating Connect object to call sub get_pt while forming a query. | ||
| 88 | |||
| 89 | my $c = WebService::UMLSKS::ConnectUMLS->new; | ||
| 90 | |||
| 91 | print "\nEnter query term:"; | ||
| 92 | |||
| 93 | my $term = <>; | ||
| 94 | |||
| 95 | # Remove white spaces. | ||
| 96 | |||
| 97 | chomp($term); | ||
| 98 | |||
| 99 | |||
| 100 | # Validate the term by passing it to the sub validateTerm which belongs to class getTerm. | ||
| 101 | # Create object of class getTerm to access the sub validateTerm. | ||
| 102 | |||
| 103 | my $valid = WebService::UMLSKS::ValidateTerm->new; | ||
| 104 | my $isTerm_CUI = $valid->validateTerm($term); | ||
| 105 | |||
| 106 | |||
| 107 | # Creating object of query and passing the method name along with parameters. | ||
| 108 | |||
| 109 | my $query = WebService::UMLSKS::Query->new; | ||
| 110 | |||
| 111 | my $cuilist; | ||
| 112 | |||
| 113 | # Following sub describes the details like the method name to be called, term to be searched etc. | ||
| 114 | # Using default source SNOMECT to get the CUI back. | ||
| 115 | |||
| 116 | $service->readable(1); | ||
| 117 | $cuilist = $query->runQuery( | ||
| 118 | $service, $term, | ||
| 119 | 'findCUIByExact', | ||
| 120 | { | ||
| 121 | casTicket => $c->get_pt(), | ||
| 122 | |||
| 123 | # use SOAP::Data->type in order to prevent | ||
| 124 | # UTF-8 strings from being encoded into base64 | ||
| 125 | # http://cookbook.soaplite.com/#internationalization%20and%20encoding | ||
| 126 | searchString => SOAP::Data->type( string => $term ), | ||
| 127 | language => 'ENG', | ||
| 128 | release => '2010AA', | ||
| 129 | SABs => [qw(SNOMEDCT)], | ||
| 130 | includeSuppressibles => 'false', | ||
| 131 | }, | ||
| 132 | ); | ||
| 133 | |||
| 134 | print "\nCUI/s for term $term : @$cuilist\n"; | ||
| 135 | |||
| 136 | # Serialization subroutines | ||
| 137 | |||
| 138 | # serialization -- non-Perl types / complex types | ||
| 139 | |||
| 140 | sub SOAP::Serializer::as_boolean { | ||
| 141 | my ( $self, $value, $name, $type, $attr ) = @_; | ||
| 142 | return [ $name, { 'xsi:type' => 'xsd:boolean', %$attr }, $value ]; | ||
| 143 | } | ||
| 144 | |||
| 145 | sub SOAP::Serializer::as_ArrayOf_xsd_string { | ||
| 146 | my ( $self, $value, $name, $type, $attr ) = @_; | ||
| 147 | return [ $name, { 'xsi:type' => 'array', %$attr }, $value ]; | ||
| 148 | } | ||
| 149 | |||
| 150 | |||
| 151 | |||
| 152 | #-------------------------------PERLDOC STARTS HERE------------------------------------------------------------- | ||
| 153 | |||
| 154 | |||
| 155 | =head1 SEE ALSO | ||
| 156 | |||
| 157 | getAllowablePath.pl GetUserData.pm Query.pm ConnectUMLS.pm getUMLSInfo.pl | ||
| 158 | |||
| 159 | =cut | ||
| 160 | |||
| 161 | |||
| 162 | =head1 AUTHORS | ||
| 163 | |||
| 164 | Mugdha Choudhari University of Minnesota Duluth | ||
| 165 | E<lt>chou0130 at d.umn.eduE<gt> | ||
| 166 | |||
| 167 | Ted Pedersen, University of Minnesota Duluth | ||
| 168 | E<lt>tpederse at d.umn.eduE<gt> | ||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | =head1 COPYRIGHT | ||
| 174 | |||
| 175 | Copyright (C) 2011, Mugdha Choudhari, Ted Pedersen | ||
| 176 | |||
| 177 | This program is free software; you can redistribute it and/or modify | ||
| 178 | it under the terms of the GNU General Public License as published by | ||
| 179 | the Free Software Foundation; either version 2 of the License, or (at | ||
| 180 | your option) any later version. | ||
| 181 | |||
| 182 | This program is distributed in the hope that it will be useful, but | ||
| 183 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 184 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 185 | General Public License for more details. | ||
| 186 | |||
| 187 | You should have received a copy of the GNU General Public License | ||
| 188 | along with this program; if not, write to | ||
| 189 | The Free Software Foundation, Inc., | ||
| 190 | 59 Temple Place - Suite 330, | ||
| 191 | Boston, MA 02111-1307, USA. | ||
| 192 | |||
| 193 | =cut | ||
| 194 | |||
| 195 | #---------------------------------PERLDOC ENDS HERE--------------------------------------------------------------- |