Testing the SHR module using cURL
cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. It can also be used to test the SHR module by making test requests via command line.
Installing cURL on your system
cURL can be downloaded from here. Follow the instructions given therein to install it.
cURL for testing GET requests
A sample GET request is as follows -
curl -i -u "admin:Password1" "http://localhost:8080/openmrs/ws/rest/RHEA/patient/encounters?patientId=1234&idType=ECID
This request contains the user name / password of the application under test, the url, and several parameters. Other optional parameters may also be added for further testing.
This request will print out the retrived hl7 message into your console.
Incorrect cURL commands will contain missing / invalid parameters
cURL for testing POST requests
Testing the POST request is comparatively harder. A sample POST request will be as follows -
curl -i -u admin:Password1 -X POST -H "Content-Type: application/xml" --data @hl7message.xml http://localhost:8080/openmrs/ws/rest/RHEA/patient/encounters?patientId=1234&idType=ECID
Note the use of the additional parameters, 'content-type' and the 'data'
The xml file we point to via the 'data' parameter contains the xml formatted message we wish to post, while the 'content-type' header specifies the format of the message.
.