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

(feat) Introduce Location Datasource #113

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

kajambiya
Copy link
Collaborator

@kajambiya kajambiya commented Aug 22, 2023

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR introduces the location data source. It allows locations to be captured as obs with the help of the ui-select-extended control.
The PR also includes some code refactor to the data-source component.

Screenshots

Screen.Recording.2023-08-22.at.09.17.25.mov

Related Issue

Other

src/datasources/data-source.ts Outdated Show resolved Hide resolved
src/datasources/data-source.ts Outdated Show resolved Hide resolved
src/datasources/data-source.ts Show resolved Hide resolved
src/datasources/data-source.ts Outdated Show resolved Hide resolved
src/api/types.ts Show resolved Hide resolved
Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

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

Nice work @kajambiya. Just a few minor comments

@kajambiya kajambiya changed the title O3-2266 OHRI-1610 Introduce Location Datasource OHRI-1610 O3-2266 Introduce Location Datasource Sep 12, 2023
import { DataSource } from '../api/types';

export class LocationDataSource implements DataSource<OpenmrsResource> {
private initialUrl: string;
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this?


toUuidAndDisplay(data: OpenmrsResource): OpenmrsResource {
if (typeof data.uuid === 'undefined' || typeof data.display === 'undefined') {
throw new Error();
Copy link
Member

Choose a reason for hiding this comment

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

Can you provide an error message? Something like:

throw new Error("'uuid' or 'display' not found in the OpenMRS object.");

}

fetchData(searchTerm: string, config?: Record<string, any>): Promise<any[]> {
this.url = this.initialUrl;
Copy link
Member

@samuelmale samuelmale Sep 14, 2023

Choose a reason for hiding this comment

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

Are there cases where you envision the URL changing for this Datasource? Why parameterize it? Why not fuse it within assuming this Datasource will only be used for locations? Ideally, it should accept adhoc query params through configurations and the search term but I'm not sure I understand why we require a URL in the constructor.

The parameter only makes sense for data sources whose URL might change like the base data source.

@samuelmale samuelmale changed the title OHRI-1610 O3-2266 Introduce Location Datasource (feat) Introduce Location Datasource Sep 14, 2023
Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @kajambiya

@samuelmale samuelmale merged commit fabd48d into openmrs:main Sep 18, 2023
7 checks passed
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.

3 participants