Last active
May 7, 2019 16:46
-
-
Save TheZorkij/fadd199849a388bbc6353f74149dcca9 to your computer and use it in GitHub Desktop.
FHIR Conditional operations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var client = Fhir({ | |
| baseUrl: process.env.SERVER_URL || 'http://localhost:8888', | |
| debug: process.env.DEBUG || false, | |
| auth: {user: '[email protected]', pass: 'secret'} | |
| }); | |
| //CONDITIONAL OPERATIONS | |
| //conditionalUpdate | |
| const conUpdate = function() { | |
| client.update({ | |
| resource: { | |
| //... | |
| }, | |
| query: { | |
| //... | |
| } | |
| }).catch(function(err) { | |
| // Error responses | |
| if (err.status) { | |
| console.log(err); | |
| console.log('Error', err.status); | |
| } | |
| // Errors | |
| if (err.data && err.data) { | |
| console.log('Error', err.data); | |
| } | |
| }); | |
| }; | |
| //conditionalDelete | |
| const conDelete = function() { | |
| client.delete({ | |
| resource: { | |
| //... | |
| }, | |
| query: { | |
| //... | |
| } | |
| }).catch(function(err) { | |
| if (err.status) { | |
| console.log(err); | |
| console.log('Error', err.status); | |
| } | |
| if (err.data && err.data) { | |
| console.log('Error', err.data); | |
| } | |
| }); | |
| }; | |
| //conditionalCreate | |
| const conCreate = function() { | |
| client.create({ | |
| resource: { | |
| //... | |
| }, | |
| headers: { | |
| 'If-None-Exist': '...' | |
| } | |
| }).catch(function(err) { | |
| if (err.status) { | |
| console.log(err); | |
| console.log('Error', err.status); | |
| } | |
| if (err.data && err.data) { | |
| console.log('Error', err.data); | |
| } | |
| }); | |
| }; | |
| //conditionalRead | |
| const conRead = function() { | |
| const res = client.read({ | |
| resource: { | |
| //... | |
| }, | |
| headers: { | |
| 'If-None-Match': '...', | |
| 'If-Modified-Since': '...' | |
| } | |
| }).then(function(res) { | |
| const bundle = res.data; | |
| console.log(JSON.stringify(bundle.entry, null, 1)); | |
| }).catch(function(err) { | |
| if (err.status) { | |
| console.log(err); | |
| console.log('Error', err.status); | |
| } | |
| if (err.data && err.data) { | |
| console.log('Error', err.data); | |
| } | |
| }); | |
| }; | |
| //conditionalPatch - not supported by Aidbox | |
| const conPatch = function() { | |
| client.patch( { | |
| resource: { | |
| //... | |
| }, | |
| query: { | |
| //... | |
| } | |
| }).catch(function(err) { | |
| if (err.status) { | |
| console.log(err); | |
| console.log('Error', err.status); | |
| } | |
| if (err.data && err.data) { | |
| console.log('Error', err.data); | |
| } | |
| }); | |
| }; |
niquola
commented
May 7, 2019
operation( { ...., headers: {} } )
create( { resource: {rt, [id]}, headers: {"if-Not-Exists": <query>}, } )
update( {
resource: {
rt, [id]
} ,
query: <query>,
headers: {
"If-Match": 'versionId'
}
})
delete( {resource: {rt, [id]}, query <query>} )
read( {
resource: {rt,id},
headers: {
"If-None-Match": <version-id>,
"If-Modified-Since": <last-updated>
}
})
name=ivan,petr
name=ivan&name=petrov
date=lt20&date=gt30
_filter=(given=ivan and family = petrov) or (birthDate > 1999)
patch()
search({
type: 'Patient',
params: {
name: ['ivan', 'petr'],
identifier: {and: ['77777', 'aaaa333']},
date: { lt: 20, gt: 30 },
//????
id: []
lastUpdated: '....'
tag: '...'
profile: '...'
security: '...'
},
chained: {
subject: {
Patient: {
organization: {
Organization: {name: 'Clinic...'}}}
}
include: {
managingOrganization: { resourceType: 'Organization', iterate: true}
},
revinclude: {
Encounter: 'subject'
},
sort: [{asc: 'name'}, {desc: 'birthDate'}],
summary: true,
elements: ['telecome', 'name.given'],
paging: { count: 40, page: 5}
total: 'count',
})
transaction()
batch()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment