-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
170 additions
and
28,295 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import axios from 'axios' | ||
import { R4 } from '@ahryman40k/ts-fhir-types'; | ||
|
||
/** | ||
* | ||
*/ | ||
export class FhirBackend { | ||
|
||
baseUrl: string = '' | ||
questionnaireBundle: R4.IBundle = { | ||
resourceType: "Bundle" | ||
} | ||
|
||
constructor(baseUrl: string){ | ||
if(baseUrl != '') | ||
this.baseUrl = baseUrl; | ||
}; | ||
|
||
async initialize() { | ||
const response = await axios.get(this.baseUrl + '/Questionnaire') | ||
this.questionnaireBundle = response.data | ||
} | ||
|
||
getQuestionnaires(): R4.IBundle { | ||
return this.questionnaireBundle; | ||
} | ||
|
||
getTableOfContents(){ | ||
return this.questionnaireBundle?.entry?.map(entry => {return {fullUrl: entry.fullUrl, id: entry.resource?.id}}) | ||
} | ||
|
||
getQuestionnaire(id: string){ | ||
return this.questionnaireBundle?.entry?.find(entry => { | ||
return entry.resource?.id === id | ||
})?.resource | ||
} | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { FhirJsonForm } from './ques-mapper'; | ||
export { FhirJsonResp } from './resp-mapper'; | ||
export { FhirBackend } from './fhir-backend'; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FhirBackend } from '../src/fhir-backend' | ||
import { R4 } from '@ahryman40k/ts-fhir-types'; | ||
|
||
describe('Testing Fhir Backend', () => { | ||
|
||
const backend = new FhirBackend('http://hapi.fhir.org/baseR4'); | ||
beforeAll( async () => { | ||
await backend.initialize() | ||
}); | ||
|
||
it('gets questionnaires on FHIR server', async () => { | ||
|
||
if(backend.getQuestionnaires() != undefined){ | ||
const bundle: R4.IBundle = backend.getQuestionnaires() | ||
expect(bundle.resourceType).toBe('Bundle') | ||
}else{ | ||
throw new Error("Bundle not found"); | ||
} | ||
}); | ||
|
||
it('gets table of contents', async () => { | ||
const toc: unknown = backend.getTableOfContents() | ||
expect(toc).toBeTruthy() | ||
}); | ||
|
||
it('gets single questionnaire', async () => { | ||
if (backend.getQuestionnaire('2050148') != undefined) { | ||
const questionnaire: R4.IResourceList = backend.getQuestionnaire('2050148')! | ||
expect(questionnaire.id).toBe('2050148') | ||
} else { | ||
throw new Error("Bundle not found"); | ||
} | ||
}); | ||
}); |