-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Encounter Provider Control
- Loading branch information
Showing
15 changed files
with
105 additions
and
13 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 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
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
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,28 @@ | ||
import { openmrsFetch } from '@openmrs/esm-framework'; | ||
import { BaseOpenMRSDataSource } from './data-source'; | ||
|
||
export class ProviderDataSource extends BaseOpenMRSDataSource { | ||
constructor() { | ||
super('/ws/rest/v1/provider?v=custom:(uuid,display)'); | ||
} | ||
|
||
fetchData(searchTerm: string, config?: Record<string, any>, uuid?: string): Promise<any[]> { | ||
let apiUrl = this.url; | ||
const urlParts = apiUrl.split('?'); | ||
if (config?.tag) { | ||
apiUrl = `${urlParts[0]}?tag=${config.tag}&${urlParts[1]}`; | ||
} | ||
//overwrite url if there's a uuid value, meaning we are in edit mode | ||
if (uuid) { | ||
apiUrl = `${urlParts[0]}/${uuid}?${urlParts[1]}`; | ||
} | ||
|
||
return openmrsFetch(searchTerm ? `${apiUrl}&q=${searchTerm}` : apiUrl).then(({ data }) => { | ||
if (data.results) { | ||
console.log(data.results); | ||
return data.results; | ||
} | ||
return data; | ||
}); | ||
} | ||
} |
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
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
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
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,24 @@ | ||
import { SubmissionHandler } from '..'; | ||
import { getEncounterProviders } from '../api/api'; | ||
import { OpenmrsEncounter, OHRIFormField } from '../api/types'; | ||
import { EncounterContext } from '../ohri-form-context'; | ||
|
||
export const EncounterProviderHandler: SubmissionHandler = { | ||
handleFieldSubmission: (field: OHRIFormField, value: any, context: EncounterContext) => { | ||
context.setEncounterProvider(value); | ||
return value; | ||
}, | ||
getInitialValue: (encounter: OpenmrsEncounter, field: OHRIFormField, allFormFields?: OHRIFormField[]) => { | ||
return new Date(); // TO DO: pick it from the visit if present | ||
}, | ||
|
||
getDisplayValue: (field: OHRIFormField, value: any) => { | ||
if (!field.value) { | ||
return null; | ||
} | ||
return value; | ||
}, | ||
getPreviousValue: (field: OHRIFormField, encounter: OpenmrsEncounter, allFormFields: Array<OHRIFormField>) => { | ||
return null; | ||
}, | ||
}; |