In this example we use Iguana as a web service to lookup the First Name for a patient. Incoming requests contain the Last Name, Iguana reads a database and supplies the corresponding First Names that match the surname.
In general when connecting to web services, you use the HTTP API to pull or push the data. The XML or JSON API can be very useful to parse or generate data.
If you have any questions please contact us at firstname.lastname@example.org.
Using the Code [top]
- Import the Create a webservice channel from the Builtin: Iguana Webservices repository
- Experiment with the code to find out how it works
- Start the channel
- View the result using the URL specified in the channel source component:
- Supply the Last Name and the desired result Format (XML or JSON), for example to return all patients with a surname of Smith:
Return the results as XML: http://localhost:6546/lookup?LastName=Smith&Format=xml
Return the results as JSON: http://localhost:6546/lookup?LastName=Smith&Format=json
- Adapt the code to your own requirements
- Interactive scripting help is included for this module
This is the github code for the main module:
How it works [top]
This script uses Iguana up as a web service for patient name requests. Incoming requests contain the Last Name, Iguana reads a database and supplies the corresponding First Name(s) that match the surname.
The process is fairly straightforward:
- Parse the returned data with net.http.parseRequest
- Query the Database to get patients with matching surnames
- If no surname is supplied we return the default “instruction” web page
- Serve the result into a web page using net.http.respond
More information [top]
- Source code for the main module on github
- API documentation for net.http.parseRequest, net.http.respond and json.serialize