# Care Connect API Implementation Guide - Java (code) Examples

**URL:** https://openhealthhub.org/t/care-connect-api-implementation-guide-java-code-examples/1090
**Category:** FHIR
**Created:** [13 July 2017 07:51 UTC](https://openhealthhub.org/t/care-connect-api-implementation-guide-java-code-examples/1090 "2017-07-13T07:51:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mayfield.g.kev](https://openhealthhub.org/user_avatar/openhealthhub.org/mayfield.g.kev/32/648_2.png) [@mayfield.g.kev](https://openhealthhub.org/u/mayfield.g.kev)
#### Post date: [13 July 2017 07:51 UTC](https://openhealthhub.org/t/care-connect-api-implementation-guide-java-code-examples/1090/1 "2017-07-13T07:51:27Z")

</div>

Version 1.0.0-alpha of the API was released yesterday (the webex will be available soon).

We had a few questions on test servers and JSON versions of the examples.

**_Test Server_**

We used a local version of the public HAPI server ([http://fhirtest.uhn.ca/home?serverId=hapi\_dev&pretty=false](http://fhirtest.uhn.ca/home?serverId=hapi_dev&pretty=false)) for testing out the search parameters. The easiest way to explore CareConnectAPI/FHIR is to use the public site but this supports all the FHIR Search parameters not just the common core listed in the CareConnectAPI IG.

The code for the local version is based on this post ([HOWTO Build a health database and FHIR API Server in 15 mins using open source](https://www.openhealthhub.org/t/howto-build-a-health-database-and-fhir-api-server-in-15-mins-using-open-source/155) - current github [https://github.com/KevinMayfield/Jorvik/tree/master/hapi-fhir-jpaserverDstu2](https://github.com/KevinMayfield/Jorvik/tree/master/hapi-fhir-jpaserverDstu2)) but is configured to run using maven and springboot. This can be found here: [https://github.com/nhsconnect/careconnect-java-examples/tree/master/careconnect-hapi-jpa-dstu2-springboot](https://github.com/nhsconnect/careconnect-java-examples/tree/master/careconnect-hapi-jpa-dstu2-springboot)  
This uses a embedded Apache Derby database but doesn’t include the HAPI overlay which the main version uses but is useful for a developer.

**_CareConnect Profiles Examples_**

The XML examples were again built using HAPI (java libraries) the code can be found here [https://github.com/nhsconnect/careconnect-java-examples/tree/master/ImplementationGuideExplore](https://github.com/nhsconnect/careconnect-java-examples/tree/master/ImplementationGuideExplore)  
This is also a springboot app.

When run the code will output FHIR resources in XML format to the console and post the resources to the standalone HAPI server.

To change output to JSON and where the resources are sent, your will need to use a JSON parser and alter the serverBase string. These can be found in IGExplore.java

```
`	
     IParser parser = ctxFHIR.newXmlParser();
// This is to base HAPI server not the CareConnectAPI
     String serverBase = "http://127.0.0.1:8080/FHIRServer/DSTU2/";`

```

In the example below this line of code has been changed to use the public HAPI server and JSON Parser

```
`	
     IParser parser = ctxFHIR.newJsonParser();
// This is to base HAPI server not the CareConnectAPI
     String serverBase = "http://fhirtest.uhn.ca/baseDstu2/";`
```

---

<div class="post-metadata">

### Author: ![mayfield.g.kev](https://openhealthhub.org/user_avatar/openhealthhub.org/mayfield.g.kev/32/648_2.png) [@mayfield.g.kev](https://openhealthhub.org/u/mayfield.g.kev)
#### Post date: [13 July 2017 09:10 UTC](https://openhealthhub.org/t/care-connect-api-implementation-guide-java-code-examples/1090/2 "2017-07-13T09:10:27Z")

</div>

Recording of webex [https://contattafiles.s3-us-west-1.amazonaws.com/tnt373/cl\_YDi32QUpswgS/CareConnect%20Phase%201%20Update-20170712%200958-1.mp4](https://contattafiles.s3-us-west-1.amazonaws.com/tnt373/cl_YDi32QUpswgS/CareConnect%2520Phase%25201%2520Update-20170712%25200958-1.mp4)
