HOWTO Build a health database and FHIR API Server in 15 mins using open source

Ok maybe not 15 mins but if your familiar with maven (and tomcat) it will be less than 10mins.

Instructions can be found here:

http://jamesagnew.github.io/hapi-fhir/doc_jpa.html

That gets the server running on Tomcat using an Apache Derby database. Reconfiguring to use another database is also pretty simple. A version I created can be found here:

https://github.com/KevinMayfield/AyeUp/tree/master/hapi-fhir-jpaserver

This assumes you’ve created a database in MySQL called hapifhir with user fhirjpa and password fhirjpa

But it’s pretty easy to change this to whatever you want by altering FhirServerConfig.java

public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	
	try {
		retVal.setDriver(new com.mysql.jdbc.Driver());
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	retVal.setUrl("jdbc:mysql://localhost:3306/hapifhir");
	
	retVal.setUsername("fhirjpa");
	retVal.setPassword("fhirjpa");
	return retVal;
	}

Also add the MySQL drivers to the project by adding a dependency in the pom.xml file.

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.6</version>
</dependency>

If all is in order you should be able to browse to your API server via http://localhost:8080/hapi-fhir-jpaserver/

The API should cover most requirements for apps and is the same API being adopted by Code4Health Demonstrator (Ripple OSI and Endeavour Health) and NHS England.

It doesn’t have any data but you can use examples from the FHIR website (Index - FHIR v4.3.0) or others. I’d recommend using Postman for working with the API (both XML and JSON is supported)

Ideally I’d want to put all this into a docker image and then it would be less than 15 mins to get it running.

Ideal for a hack days as it let developers get working with apps rather than messing with api’s and databases?

We have this running in our trust at the moment for evaluation taking live data feeds from our PAS, Document (EDMS) and ED systems. It’s been pretty easy so far to build sample apps (AngularJS and mumps!). We’ve not fully populated the database and stress tested but it’s holding up so far.

1 Like

Legendary! Thansk @mayfield.g.kev

Thanks.

I should mention it’s the hard work of University Health Network (Toronto) and James Agnew.

Also maybe worth another HOWTO: http://smarthealthit.org/smart-on-fhir/
from Boston and Harvard. (This covers the security side, not just for FHIR. Again open source)

@mayfield.g.kev Are you coming to any of the NHS hackdays?? I think the next one is going to be in mid-May in London (TBC)

Not London but intend to do those in the north.

thanks,i will git it a go

gave it a go, i am not looking to do anything at this time, just understand the data model - is there any supporting documentation?

The main documentation for the api is here: http://www.hl7.org/FHIR/

Endeavour Health have started extending these for UK and this can be found: http://fhir.endeavourhealth.org/profiles.html

I know people have been asking about data models but I think FHIR team have some reluctance but I just noticed a SQL variant called CQL which may be of use. A ‘chat’ about it is here https://chat.fhir.org/#narrow/stream/implementers/topic/query.20language (it’s also a good place to ask about a model)

i am up and running with this now
if i use the FHIR data model i would also need to extend it
i understand the reluctance to share in this area, this is an area that needs discussing {point of interest: by the NHS? health technicians with years of experience who have chosen to care by following an IT career pathway need rewarding app ropriately just like clinicians, and NHS leaders}

in order to support integration of H&SC i need to work out how to implement a many to many relationship between PERSON pathways (i would use the class care plan, but am not sure if this is a template {care pathway} or has an instance for each unique person)

Very interesting forum.

We are building a full remote monitoring platform (cloud and apps for user and provider) we have completed a lot of the work, including auto integration of devices, cloud analytics, clinical parameters for alerts, scheduling availability for clinician (looking to integrate to NHS system using the encore health apis, and also for medication and summary of histories etc. We also have inference deep learning engine to look at all the data from devices (medical and wellness) which will inform the alert structure.

However am very keen to build the care pathway into this model and include for instance regime, contacts (when how to triage etc )

It seems that you have very much specialised in this area of pathways for some time and appear to have possible ways to build integrations for this .

I very much welcome you reply and possible avenues for ways forward J

Best Regards

David Hollick

cid:image002.png@01D00BFE.96F82D30

T: +44 (0)01892 458998

M +44 (0) 7702 136544

Trichrome Healthcare Limited, 32 Easlands Close, Tunbridge Wells, TN4 8JX

Company registered in England and Wales No 10017866

Morning,

I’ve moved the code to a new repository https://github.com/KevinMayfield/Jorvik
and included a few apps for populating the server either from TRUD flat files, traditional HL7 and/or FHIR feed.
These are all Apache Camel apps.

Hoping to include some Spring OAuth2 examples at some point.

(also in the process of building up the documentation but it’s a huge topic. It’s roughly install java, tomcat, eclipse, git, MySQL, etc)

This is really useful. I was able to build it but now i want to change the POM file.
What i am not understanding is i dont find this group at all : uk.co.mayfieldis in the repository “https://oss.sonatype.org/content/repositories/snapshots/”.

When do you get that error?

This is very helpful. I got the server up and running.
But, and this may be a very amateur question, where is the source code that is creating the left menu lising FHIR methods (valueSet, Patient…etc) and where is the code that executes when the page is posted? I’ve searching the code and I can not find it.

Looking at the pom.xml file, it’s pulling the app/war file

<dependency>
		<groupId>ca.uhn.hapi.fhir</groupId>
		<artifactId>hapi-fhir-testpage-overlay</artifactId>
		<version>${hapi-fhir-version}</version>
		<type>war</type>
		<scope>provided</scope>
	</dependency>

This should be the hapi code in git https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-testpage-overlay (looks like a mix of java and angularJS)

This contains the most part of the server code - the main hapi side may be more useful http://hapifhir.io/

Also for help on hapi, try https://chat.fhir.org/# or this googlegroup https://groups.google.com/forum/#!forum/hapi-fhir

Thank you for the reply! I appreciate it.

Hi Kev,
Thank you for your post. I am new to maven. I followed JPA server setup. I am getting the error when installing maven using the command “mvn install” .
Could you please explain it?

I think you’ve used the older repository, the latest one is here

But I think the problem was with maven repositories and may work if you try again.

1 Like

@mayfield.g.kev,

Thanks for your solution. Please note that the following worked for me in getting MySQL hooked up:

	private Properties jpaProperties() {
		Properties extraProperties = new Properties();
		//extraProperties.put("hibernate.dialect",  org.hibernate.dialect.DerbyTenSevenDialect.class.getName()); // CHANGE 1
		extraProperties.put("hibernate.format_sql", "true");
		extraProperties.put("hibernate.show_sql", "false");
		extraProperties.put("hibernate.hbm2ddl.auto", "create"); // CHANGE 2
		extraProperties.put("hibernate.jdbc.batch_size", "20");
		extraProperties.put("hibernate.cache.use_query_cache", "false");
		extraProperties.put("hibernate.cache.use_second_level_cache", "false");
		extraProperties.put("hibernate.cache.use_structured_entries", "false");
		extraProperties.put("hibernate.cache.use_minimal_puts", "false");
		extraProperties.put("hibernate.search.default.directory_provider", "filesystem");
		extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles");
		extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
//		extraProperties.put("hibernate.search.default.worker.execution", "async");
		return extraProperties;
	}
  • CHANGE 1 is that this had to be commented out.
  • CHANGE 2 is that this had to be tweaked so that the database tables would be created.

Thanks,
Matthew Vita

Thanks.

I’ve changed the code slightly, your first change is now a configuration setting. Maybe the second change should be one also?

I’ve been using this repo recently https://github.com/nhsconnect/careconnect-java-examples/tree/master/careconnect-hapi-jpa-dstu2-springboot Thats aimed at running a FHIR server locally (using spring boot) rather than on an application server. We used it to build the UK version of Argonaut (https://nhsconnect.github.io/CareConnectAPI/explore.html)