Giter Club home page Giter Club logo

graphql-fhir's Introduction

GraphQL-FHIR Build Status Coverage Status GitHub license

A secure GraphQL implementation for the HL7 FHIR specification based on the current implementation guide for GraphQL with FHIR and developed with Node.js and Express.

Prerequisites

You should have a basic understanding of working in Node.js and at least a basic understanding of what GraphQL is and how it works.

Getting Started

  1. Installation
git clone https://github.com/Asymmetrik/graphql-fhir.git
cd graphql-fhir
yarn install
  1. Start a local dev server
# For development
yarn nodemon
  1. View http://localhost:3000/3_0_1/$graphiql to explore the available queries and mutations in the graphiql interface. The standard graphql endpoint is available at http://localhost:3000/3_0_1/$graphql.

What's next

See our Frequently Asked Questions for explanations on how to configure the server, connect to an actual database, setup authentication, and more. You can also read up on the project structure under the Architecture section if you are curious about that kind of thing. If you are want to know about our future plans, see our Roadmap. If you have any other questions, please ask them on StackOverflow with the tag graphql-fhir.

Frequently Asked Questions

Architecture

We designed this project in the way that we did so we can support multiple versions simultaneously and add new versions very quickly. Everything in src/resources is generated by an internal tool that reads Structure Definitions downloaded from the official FHIR website. The tool output's schemas, inputs, parameter files, custom scalars, and profile endpoints, which includes files used to register queries and mutations with the server as well as resolvers.

If you decide to use this server, you will rarely need to modify code in src/resources except for code in the profiles, since this is where you add resolver logic and configure which profiles you want to support.

The folder structure for the project looks like this:

src
| - config.js
| # Contains server and version configuration 
| - index.js
| # Entry to the application
| - src/lib
| # Contains custom libs we use, server, logger's, etc
| - src/middleware
| # Custom express middleware
| - src/scripts
| # Scripts for local development and testing.
| - src/utils
| # Various utilities used throughout the application
| - src/resources
| # All the code in here is auto generated for each version
|  | - 3_0_1
|  | # This directory contains all the 3_0_1 logic
|  |  | - inputs
|  |  | # Contains all input schemas for mutations
|  |  | - parameters
|  |  | # Defines what arguments can be provided to search operations.
|  |  | - scalars
|  |  | # Contains some custom FHIR types.
|  |  | - schemas
|  |  |  # Defines all the output schemas.
|  |  | - profiles
|  |  |  # Contains all the configurable profiles for GraphQL.
|  |  |  | - patient # or any other resource for that matter
|  |  |  |  | - index.js
|  |  |  |  | # File used to register capabilities with the server
|  |  |  |  | - mutation.js
|  |  |  |  | # Mutations configuration. Auto-Generated and should not modify
|  |  |  |  | - query.js
|  |  |  |  | # Query configuration. Auto-Generated and should not modify 
|  |  |  |  | - resolver.js
|  |  |  |  | # Contains placeholders, your logic to query your backend goes here.

Roadmap

  • Authentication Initializers and passport support
  • Better documentation on setup and configurations
  • Change return format for ResourceList queries to a FHIR Bundle instead of a GraphQLList
  • Implementation guides and demos
  • Support for more resources
    • USCore resources.
  • Support for more versions
    • DSTU2 (1.0.2).
    • STU3 (3.0.1).
    • R4
  • Work with community to continue to establish best practices for FHIR with GraphQL and implement them here.

Contributing

Please see CONTRIBUTING.md for more details regarding contributing issues or code.

License

graphql-fhir is MIT licensed.

graphql-fhir's People

Contributors

jamesburton avatar jgrasso2 avatar luan-dev avatar rafmos avatar robert-w avatar s1monj avatar sshah-asymmetrik avatar sureshhardiya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-fhir's Issues

Need Help with audit events

We wanted help in fhir implementation to log events when any change in the organization , practitioner, practitioner role etc. Can you help us what is the correct way to do it.

ResourceList Query [Question]

Hello,
For QuestionnaireList, isn't it enough returning array from resolver as follow ?

[ 
{ _id: 'teee',
   id: 'teee',
   resourceType: 'Questionnaire',
   title: 'Some title',
   status: 'active' 
   .
   .
   .
   },
   { ... }
]

Everytime I am only getting back

{
  "data": {
    "QuestionnaireList": {
      "entry": null
    }
  }
}

Below is my query I used in /$graphiql

{
  QuestionnaireList(status: "active") {
    entry {
      resource {
        ... on Questionnaire {
          resourceType
          id
        }
      }
    }
  }
}

Am I missing something here ?

Below is piece of my resolver

return new Promise((resolve, reject) => {
		collection.find(args).toArray((err, questionnaires) => {
		      if (err) {
		        logger.error(err);
		        let error = errorUtils.internal(version, err.message);
		        return reject(errorUtils.formatErrorForGraphQL(error));
		      } else {
		        return resolve(questionnaires);
		      }
		    });
	});

Support for newer releases

Question : What is the plan to support R4B & R5 releases when they happen ? Is the plan to make them available only after they are officially approved ?

Resources storage structure [Question]

Hello,
I am using graphql-fhir and using mongo as db.
What structure do you suggest to use for different versions of resources ?
a. Store in same collection and map according to versions
b. Store in different collection as Patient_1_0_2, Patient_3_0_1 etc ?

Regarding R4

Can i know when the R4 version will be available?

Request for running against revised FHIR specifications, particularly UKCore R4

I would like to generate the resources for UKCore's R4 specification

Is there a method included with which we can generate against modified FHIR specifications, specifically for me the UKCore R4 implementation?

If it is possible for you guys to point at that and re-run the generators in a UKCoreR4 branch that would be amazing, but if you can point me in the right direction I'm also happy to act as a contributor here too.

Internal tool to generate FHIR profiles

Can you provide the internal tool mentioned in README to generate the FHIR profiles ? This is needed as many countries are having their own versions of the FHIR profiles. For example US has their own core profile Datasets, India has their own, that I know of. Access to the tool would help reuse the tool, and minimize errors

Regarding Microservices

We are using the Asymetrik graphql-fhir. Does it run individual micro services for each resource(i.e. Patient , Practitioner e.t.c) independently?

Unable to insert answerOption in Questionnaire Resource

Do you want to submit a request for change, improve documentation, or ask a question?

  • request for change, and ask a question

If reporting a bug, please answer the following at minimum and add any additional information you think may be helpful

What is the current behavior?
After defining resolvers and my Database connection, I tried to insert a questionnaire.
If you take for example questionnaire as shown in here:

It has answerOption:

"answerOption": [
                {
                  "valueCoding": {
                    "code": "F"
                  }
                },
                {
                  "valueCoding": {
                    "code": "M"
                  }
                }
              ]

But since schema requires other values to be not here we get error saying valueInteger, valueString and others are required.

What is the expected behavior?
As shown in [the documentation] (http://hl7.org/fhir/questionnaire.html#resource)
Screenshot 2019-05-09 at 16 34 43

If a question has only two options which are valueCoding, we should not have to define other values?

What are the steps to reproduce?
I tried a mutation to create a questionnaire with answerOption. However, if I remove GraphQLNonNull from the lines: https://github.com/Asymmetrik/graphql-fhir/blob/master/src/resources/4_0_0/schemas/questionnaireitemansweroption.schema.js#L47, it works fine. So, my question would be, if we define answerOption, do we really need to define all those [valueCoding, valueInteger, valueDecimal, valueDate, valueTime, valueReference].

What OS are you using and what version of node.js and @asymmetrik/graphql-fhir are you running?

  • node js: 10.0.0
  • OS: MAC

PS: If GraphQLNonNull is not required according to HL7 FHIR R4 definitions, I can create a PR if you like.

Regards,
Suresh

Instance Query [Question]

Hello,

Following is the InstanceQuery I tried

http://localhost:3000/3_0_1/Questionnaire/jamana/$graphql?query={id}

I am receiving back response as Cannot query field \"id\" on type \"Questionnaire_Query\"

So what is the right format I should try ?

https://build.fhir.org/graphql.html has a sample as http://test.fhir.org/r3/Patient/example/$graphql?query={name{text,given,family}}.Its working in their server. I cannot get the response When I try similarly in our graph-fhir.

New extension to an existing resource

Can you please guide us on how can we add a new custom extension to an existing resource

Example: like "gender" for a Practitioner resource. I need to add "custom" extension to a resource.

Is there a plan to support graphQL directives like @flatten and @first?

Do you want to submit a request for change, improve documentation, or ask a question?

If asking a question, please attach the 'Question' label

If reporting a bug, please answer the following at minimum and add any additional information you think may be helpful

What is the current behavior?

What is the expected behavior?

What are the steps to reproduce?

What OS are you using and what version of node.js and @asymmetrik/graphql-fhir are you running?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.