Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mCSD Changes plus more #122

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

mCSD Changes plus more #122

wants to merge 34 commits into from

Conversation

lukeaduncan
Copy link
Contributor

This was the changes I did to add in mCSD and mACM support which are built in STU3. Also added in FHIR.js for XML conversions.

…not supported as it returns data in the metadata collection by default, although that probably needs to be corrected. Allowed upsert with PUT.
…L to update. This needs to be modified to store some configuration about which resources to load on a regular basis. Perhaps also saving them in a separate databse or maybe that's better handled by having a separate server with a different DB configuration.
…). Made the update supplier api call more robust depending on what is returned to fail more gracefully. Updated some search queries.
… the ATNA message in searchFilters when it is chained. Added DELETE message to history when a resource is deleted. Fixed history message to display messages from the history collection correctly on the _history action.
Copy link
Member

@rcrichton rcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lduncan-intrah Thanks! This looks very good to me. I've added comments to the PR, but mostly what we need for this PR is to:

  • Add some tests for the new functionality
  • Update the minor styling issues so the linter (standard.js) doesn't complain and the build passes on travis
  • A few updates to make the code work with our latest commits. Merging in our new master to this branch would be needed.

Let us know if you can focus on these things and if we can help at all.

@@ -360,9 +360,16 @@ module.exports = exports = (mongo) => {
if (entry._mpi) {
search = entry._mpi.search
}
if ( entry._request.method == 'POST' ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: we should always use triple equals ===

@@ -543,7 +550,7 @@ module.exports = exports = (mongo) => {
*/
getPagingParams: (queryParams, callback) => {
let _getpagesoffset = 0
let _count = 10
let _count = 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this to the default of 10. It can always be overridden by the client.

@@ -430,7 +566,7 @@ module.exports = (mongo, modules) => {
resource.meta.versionId = fhirCommon.util.generateID()

const options = {
upsert: false, // TODO OHIE-168
upsert: true, // TODO OHIE-168
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make this configurable via a config option with a default of false.

@@ -459,7 +585,26 @@ module.exports = (mongo, modules) => {
const location = `/fhir/${resourceType}/${id}/_history/${resource.meta.versionId}`
callback(null, { httpStatus: 200, location: location, id: id })
})
})
//return callback(null, fhirCommon.buildHTTPOutcome(404, 'information', 'not-found', 'Not found'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we still need this instead of the callback at line 586?


if (queryObject['organization.active']) {
promises.push(new Promise((resolve, reject) => {
queryUtils.genChainedParamQuery(queryObject['organization.active'][constants.NO_MODIFER], 'managingOrganization.reference', 'active', organization, (err, clause) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In one of our recent commits we changes how fhirModules are passed to this function. All uses of this will need minor adaptation.

@@ -178,7 +185,11 @@ app.get('/fhir/:resourceType', (req, res, next) => {
fhirCore.search(res.locals.ctx, req.params.resourceType, buildCoreCallbackHandler(req, res, next))
})
app.get('/fhir/:resourceType/:id', (req, res, next) => {
fhirCore.read(res.locals.ctx, req.params.resourceType, req.params.id, buildCoreCallbackHandler(req, res, next))
if ( req.params.id == '_history' ) {
fhirCore.history(res.locals.ctx, req.params.resourceType, buildCoreCallbackHandler(req, res, next))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add tests to verify that this is working as expected.

@@ -220,7 +232,18 @@ const outcomeHandler = (req, res, next) => {
res.set('Location', res.locals.outcome.location)
}
if (res.locals.outcome.resource) {
res.status(res.locals.outcome.httpStatus).send(res.locals.outcome.resource)
var output = res.locals.outcome.resource;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed to as it is handled in out latest commits.

{ $lookup: { from: resourceType+"_history", pipeline: [], as: "history" } },
{ $project: { all: { $setUnion: [ "$top", "$history" ] } } },
{ $unwind: "$all" },
{ $replaceRoot: { newRoot: "$all" } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps another way to do this would be to just to two separate queries and combine the results? Might be more efficient. Although this way seems fine to until we actually see a performance issue.

@@ -237,7 +244,119 @@ module.exports = (mongo) => {
}
return addToClause(value)
},
*/

nameToMongoClause: (fieldToMatch, value, modifier) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally add test for each new resource we add and all search parameters for this. But in this case that is a lot of work. So, I'd suggest only writing tests for the search parameters were we use these new query utils functions so that we get coverage of these functions and ensure they do what we expect.


if (queryObject['organization.active']) {
promises.push(new Promise((resolve, reject) => {
queryUtils.genChainedParamQuery(queryObject['organization.active'][constants.NO_MODIFER], 'organization.reference', 'active', organization, (err, clause) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have changed the way genChainedParamQuery works. It not accepts an array of fhirModules in the latest commits. We believe we will need to change how we are passing the fhir module to this function in each case where it's used in this PR. It shouldn't be too much different.

Copy link
Contributor

@BMartinos BMartinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lduncan-intrah this is looking great so far, Just added a few comments but overall looking good,

The main points of concern i have is that a lot of the resource updates have been changed to support FHIR DSTU3. At the moment hearth only supports DSTU2. Adding new resources, or additional supported parameters for a resource is fine i think, its more the ones that are changed and remove that might cause some issues.

We still need to come up with a nice way to support all FHIR versions, and any new ones that might come in future.

if ( myURL.search ) {
path = path+myURL.search
}
console.log( myURL.hostname +' '+myURL.port+' '+path+' '+myURL.protocol);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console.log()

* @param {CoreCallback} callback
*/
pullUpdates: (ctx, callback) => {
console.log(ctx.query.url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console.log()

@@ -360,9 +360,16 @@ module.exports = exports = (mongo) => {
if (entry._mpi) {
search = entry._mpi.search
}
if ( entry._request.method == 'POST' ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check indentation
remove spaces within condition braces
update condition to be ===

if ( entry._request.method == 'POST' ) {
entry._request.url = entry.resourceType
} else {
entry._request.url = entry.resourceType+"/"+entry.id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update variable to be defined in an template Literal way, making it easier to read
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

@@ -543,7 +550,7 @@ module.exports = exports = (mongo) => {
*/
getPagingParams: (queryParams, callback) => {
let _getpagesoffset = 0
let _count = 10
let _count = 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reverted to the default of 10, A query parameter (_count) can be sent to increase the paging count, If this is set to _count=0 then all results will be returned

@@ -0,0 +1,112 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this module can be removed due to Hearth having integrated content negotiation to transform the payload content type, Payloads can now be returned in XML or JSON based on the Accepts and Content-Type headers

@@ -66,7 +67,8 @@ const fhirRoot = require('./fhir/root')(mongo, fhirResources)
// Setup express
let app = express()

app.use(bodyParser.json({limit: '10Mb', type: ['application/json+fhir', 'application/json']}))
app.use(bodyParser.json({limit: '10Mb', type: ['application/fhir+json', 'application/json+fhir', 'application/json']}))
app.use(bodyParser.text({limit: '10Mb', type: ['application/fhir+xml', 'application/xml+fhir', 'application/xml']}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed, as XML types are now handled with the new content negotiation changes that were added to Hearth

@@ -159,6 +162,10 @@ const buildCoreCallbackHandler = (req, res, next) => {
}
}

app.get('/api/supplyUpdates', (req, res, next) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure if this should be included directly into Hearth, and a better fit might be to have this endpoint as a separate microservice sitting next to hearth. If this is quite dependant on some of the hearth core functions, we might need to find a better way for custom endpoints

@@ -198,7 +209,8 @@ app.delete('/fhir/:resourceType/:id', (req, res, next) => {

const returnContentTypeHandler = (req, res, next) => {
if (res.locals.outcome && res.locals.outcome.resource) {
const accepts = req.accepts(['application/json+fhir', 'application/json'])
const accepts = req.accepts(['application/fhir+json', 'application/json+fhir', 'application/json', 'json',
'application/fhir+xml', 'application/xml+fhir', 'application/xml', 'xml'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be reverted due to content negotiation being added to hearth

var fhir = new Fhir(Fhir.STU3);
output = fhir.ObjectToXml( output );
}
res.status(res.locals.outcome.httpStatus).send(output)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above changes can be reverted due to content negotiation being added to hearth

@citizenrich
Copy link

@rcrichton @lduncan-intrah Wanted to see if we are stuck on something here. I don't see commits to the master branch since mid-Feb.

…he context to be passed along. e.g. /DBNAME/fhir/RESOURCE. Not including DBNAME will use the default database.
…he context to be passed along. e.g. /DBNAME/fhir/RESOURCE. Not including DBNAME will use the default database. This needs more complete testing and the worker thread isn't set up to attach to multiple databases since that is started at server time and not connected to the database name. Further updates will be needed to configure workers per database.
…/grandchildren/etc. of a Location based on the partOf.reference. /fhir/Location/ID/$hierarchy. It returns a Bundle of type "searchset".
…view so the connectToField will always use a direct field instead of a modified field in the view for faster access.
lukeaduncan and others added 7 commits June 25, 2018 14:40
…view and graphLookup for this, it was changed to pulling all the data and handling it inside Hearth to filter the results. graphLookup was running out of memory for large datasets and even simplifying that for the current data sets still took a long time to run. This option is currently much faster but may need to be reviewed for even larger datasets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants