Skip to content

Commit

Permalink
Use @beda.software/remote-data and @beda.software/fhir-react
Browse files Browse the repository at this point in the history
  • Loading branch information
ir4y committed Jun 17, 2024
1 parent d929619 commit 7de1056
Show file tree
Hide file tree
Showing 28 changed files with 74 additions and 62 deletions.
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"version": "0.3.1",
"private": true,
"dependencies": {
"@beda.software/fhir-react": "^1.8.6",
"@beda.software/remote-data": "^1.1.3",
"@codemirror/commands": "^6.2.4",
"@codemirror/language": "^6.9.0",
"@codemirror/legacy-modes": "^6.3.3",
Expand Down Expand Up @@ -36,7 +38,6 @@
"babel-loader": "8.1.0",
"babel-plugin-import": "^1.13.3",
"classnames": "^2.3.1",
"fhir-react": "https://github.com/beda-software/fhir-react.git",
"fhirpath": "^3.5.0",
"final-form": "^4.20.4",
"final-form-arrays": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/LaunchContextEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FhirResource, Parameters, ParametersParameter, Questionnaire } from 'fh
import { useMemo, useState } from 'react';
import { SingleValue } from 'react-select';

import { success } from 'fhir-react/lib/libs/remoteData';
import { success } from '@beda.software/remote-data';

import { groupLaunchContextParams } from './groupLaunchContextParams';
import s from './LaunchContextEditor.module.scss';
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/ModalExpression/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { extractParameterName } from 'web/src/components/ModalExpression/utils';
import { ExpressionResultOutput } from 'web/src/containers/Main/types';
import YAML, { visitor } from 'yaml';

import { useService } from 'fhir-react/lib/hooks/service';
import { isSuccess } from 'fhir-react/lib/libs/remoteData';
import { service } from 'fhir-react/lib/services/service';
import { useService } from '@beda.software/fhir-react';
import { isSuccess } from '@beda.software/remote-data';
import { service } from 'src/services/fhir';

import { QuestionnaireResponse } from 'shared/src/contrib/aidbox';

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/ModalExpression/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InputField } from 'web/src/components/InputField';
import { useExpressionModal } from 'web/src/components/ModalExpression/hooks';
import { ResourceCodeDisplay } from 'web/src/components/ResourceCodeDisplay';

import { isSuccess, RemoteData } from 'fhir-react/lib/libs/remoteData';
import { isSuccess, RemoteData } from '@beda.software/remote-data';

import s from './ModalExpression.module.scss';
import { ModalExpressionProps } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import fhirpath from 'fhirpath';
import { ActionMeta, MultiValue, SingleValue } from 'react-select';
import { loadResourceOptions } from 'web/src/services/questionnaire';

import { isSuccess } from 'fhir-react/lib/libs/remoteData';
import { ResourcesMap } from 'fhir-react/lib/services/fhir';
import { buildQueryParams } from 'fhir-react/lib/services/instance';
import { isSuccess, buildQueryParams } from '@beda.software/remote-data';
import { ResourcesMap } from '@beda.software/fhir-react';

import {
QuestionnaireItemAnswerOption,
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/QRFormWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { useFormContext } from 'react-hook-form';
import { RenderRemoteData } from 'web/src/components/RenderRemoteData';
import { QRFormWrapperProps } from 'web/src/containers/Main/types';

import { sequenceMap } from 'fhir-react/lib/services/service';
import { formatError } from 'fhir-react/lib/utils/error';
import { sequenceMap } from '@beda.software/remote-data';
import { formatError } from '@beda.software/fhir-react';

import { QuestionnaireResponse as FCEQuestionnaireResponse } from 'shared/src/contrib/aidbox';

Expand Down
4 changes: 2 additions & 2 deletions web/src/components/RenderRemoteData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
isNotAsked,
isSuccess,
RemoteData,
} from 'fhir-react/lib/libs/remoteData';
import { formatError } from 'fhir-react/lib/utils/error';
} from '@beda.software/remote-data';
import { formatError } from '@beda.software/fhir-react';

interface RenderRemoteDataProps<S, E = any> {
remoteData: RemoteData<S, E>;
Expand Down
7 changes: 3 additions & 4 deletions web/src/components/ResourceSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import _ from 'lodash';
import { useCallback } from 'react';
import { MultiValue, SingleValue } from 'react-select';

import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { isSuccess, RemoteData } from 'fhir-react/lib/libs/remoteData';
import { getFHIRResources, WithId } from 'fhir-react/lib/services/fhir';
import { mapSuccess } from 'fhir-react/lib/services/service';
import { RenderRemoteData, WithId} from '@beda.software/fhir-react';
import { getFHIRResources } from 'src/services/fhir';
import { mapSuccess, isSuccess, RemoteData } from '@beda.software/remote-data';

import s from './ResourceSelect.module.scss';
import { AsyncSelect } from '../Select';
Expand Down
8 changes: 3 additions & 5 deletions web/src/components/SourceQueryDebugModal/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import * as _ from 'lodash';
import { useCallback, useState } from 'react';
import { toast } from 'react-toastify';

import { useService } from 'fhir-react/lib/hooks/service';
import { isFailure, success, isSuccess } from 'fhir-react/lib/libs/remoteData';
import { saveFHIRResource } from 'fhir-react/lib/services/fhir';
import { mapSuccess, service } from 'fhir-react/lib/services/service';
import { formatError } from 'fhir-react/lib/utils/error';
import { useService, formatError } from '@beda.software/fhir-react';
import { isFailure, success, isSuccess, mapSuccess } from '@beda.software/remote-data';
import { saveFHIRResource, service } from 'src/services/fhir';

import { Props } from './types';

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/SourceQueryDebugModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button } from 'web/src/components/Button';
import { CodeEditor } from 'web/src/components/CodeEditor';

import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { RenderRemoteData } from '@beda.software/fhir-react';

import { useSourceQueryDebugModal } from './hooks';
import s from './SourceQueryDebugModal.module.scss';
Expand Down
5 changes: 2 additions & 3 deletions web/src/containers/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { useEffect, useRef } from 'react';
import { Route, Routes, useLocation, Navigate } from 'react-router-dom';
import { setData } from 'web/src/services/localStorage';

import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { useService } from 'fhir-react/lib/hooks/service';
import { success } from 'fhir-react/lib/libs/remoteData';
import { RenderRemoteData, useService } from '@beda.software/fhir-react';
import { success } from '@beda.software/remote-data';

import { User } from 'shared/src/contrib/aidbox';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from 'web/src/components/Button';

import { formatError } from 'fhir-react/lib/utils/error';
import { formatError } from '@beda.software/fhir-react';

import { MappingEditorErrorProps } from '../interfaces';
import s from '../MappingEditor.module.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { Button } from 'web/src/components/Button';
import { ModalCreateMapper } from 'web/src/components/ModalCreateMapper';
import { Select } from 'web/src/components/Select';

import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { isFailure, isSuccess } from 'fhir-react/lib/libs/remoteData';
import { formatError } from 'fhir-react/lib/utils/error';
import { RenderRemoteData, formatError } from '@beda.software/fhir-react';
import { isFailure, isSuccess } from '@beda.software/remote-data';

import formStyles from '../../../../components/QRFormWrapper/QuestionnaireResponseForm.module.scss';
import { PromptForm } from '../../PromptForm';
Expand Down
2 changes: 1 addition & 1 deletion web/src/containers/Main/MappingEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { RenderRemoteData } from '@beda.software/fhir-react';

import { MappingEditorProps } from './interfaces';
import s from './MappingEditor.module.scss';
Expand Down
7 changes: 3 additions & 4 deletions web/src/containers/Main/MappingEditor/useMappingEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';

import { getFHIRResources as getAidboxFHIRResources } from 'aidbox-react/lib/services/fhir';

import { useService } from 'fhir-react/lib/hooks/service';
import { useService, WithId, extractBundleResources} from '@beda.software/fhir-react';
import {
RemoteData,
RemoteDataResult,
Expand All @@ -13,9 +13,8 @@ import {
isNotAsked,
isSuccess,
success,
} from 'fhir-react/lib/libs/remoteData';
import { WithId, extractBundleResources } from 'fhir-react/lib/services/fhir';
import { mapSuccess } from 'fhir-react/lib/services/service';
mapSuccess,
} from '@beda.software/remote-data';

import { Mapping } from 'shared/src/contrib/aidbox';

Expand Down
2 changes: 1 addition & 1 deletion web/src/containers/Main/PromptForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { Field, Form } from 'react-final-form';
import { Button } from 'web/src/components/Button';

import { RemoteDataResult, isFailure, isSuccess } from 'fhir-react/lib/libs/remoteData';
import { RemoteDataResult, isFailure, isSuccess } from '@beda.software/remote-data';

import s from '../../../components/QRFormWrapper/QuestionnaireResponseForm.module.scss';

Expand Down
4 changes: 2 additions & 2 deletions web/src/containers/Main/QuestionnaireEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Button } from 'web/src/components/Button';
import { ResourceCodeEditor } from 'web/src/components/ResourceCodeEditor';
import { Select } from 'web/src/components/Select';

import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { RemoteData, RemoteDataResult, isFailure, isLoading } from 'fhir-react/lib/libs/remoteData';
import { RenderRemoteData } from '@beda.software/fhir-react';
import { RemoteData, RemoteDataResult, isFailure, isLoading } from '@beda.software/remote-data';

import s from './QuestionnaireEditor.module.scss';
import { useQuestionnaireEditor } from './useQuestionnaireEditor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Questionnaire } from 'fhir/r4b';

import { useService } from 'fhir-react/lib/hooks/service';
import { extractBundleResources, getFHIRResources } from 'fhir-react/lib/services/fhir';
import { mapSuccess } from 'fhir-react/lib/services/service';
import { useService, extractBundleResources } from '@beda.software/fhir-react';
import { getFHIRResources } from 'src/services/fhir';
import { mapSuccess } from '@beda.software/remote-data';

export function useQuestionnaireEditor() {
const [questionnairesRD] = useService(async () =>
Expand Down
5 changes: 3 additions & 2 deletions web/src/containers/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import 'react-toastify/dist/ReactToastify.css';
import { ResourceCodeDisplay } from 'web/src/components/ResourceCodeDisplay';
import { version } from 'web/src/version';

import { RenderRemoteData } from 'fhir-react/lib/components/RenderRemoteData';
import { isSuccess } from 'fhir-react/lib/libs/remoteData';
import { RenderRemoteData } from '@beda.software/fhir-react';
import { isSuccess } from '@beda.software/remote-data';


import { FormRenderContext } from './context';
import s from './Main.module.scss';
Expand Down
2 changes: 1 addition & 1 deletion web/src/containers/Main/useFHIRMappingLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Bundle, QuestionnaireResponse, StructureMap } from 'fhir/r4b';
import { useCallback, useEffect, useState } from 'react';
import { convert, createStructureMap, transform } from 'web/src/services/fhirmapping';

import { isSuccess } from 'fhir-react/lib/libs/remoteData';
import { isSuccess } from '@beda.software/remote-data';

export function useFHIRMappingLanguage(questionnaireResponse: QuestionnaireResponse | undefined) {
const [fhirMappingLangMode, setFhirMappingLangMode] = useState<boolean>(false);
Expand Down
11 changes: 6 additions & 5 deletions web/src/containers/Main/useMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
saveFHIRResource as saveAidboxFHIRResource,
} from 'aidbox-react/lib/services/fhir';

import { useService } from 'fhir-react/lib/hooks/service';
import { useService, WithId } from '@beda.software/fhir-react';
import {
RemoteData,
RemoteDataResult,
Expand All @@ -27,10 +27,11 @@ import {
isSuccess,
notAsked,
success,
} from 'fhir-react/lib/libs/remoteData';
import { WithId, saveFHIRResource } from 'fhir-react/lib/services/fhir';
import { service } from 'fhir-react/lib/services/service';
import { formatError } from 'fhir-react/lib/utils/error';
} from '@beda.software/remote-data';
// import { WithId, saveFHIRResource } from 'fhir-react/lib/services/fhir';
// import { service } from 'fhir-react/lib/services/service';
import {service, saveFHIRResource} from 'src/services/fhir';
import { formatError } from '@beda.software/fhir-react';

import { Mapping } from 'shared/src/contrib/aidbox';

Expand Down
6 changes: 3 additions & 3 deletions web/src/services/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
} from 'aidbox-react/lib/services/instance';
import { service } from 'aidbox-react/lib/services/service';

import { isFailure, success } from 'fhir-react/lib/libs/remoteData';
import { isFailure, success } from '@beda.software/remote-data';
import {
resetInstanceToken as resetFHIRInstanceToken,
setInstanceToken as setFHIRInstanceToken,
} from 'fhir-react/lib/services/instance';
import { extractErrorCode } from 'fhir-react/lib/utils/error';
} from './fhir';
import { extractErrorCode } from '@beda.software/fhir-react';

import { User } from 'shared/src/contrib/aidbox';

Expand Down
2 changes: 1 addition & 1 deletion web/src/services/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { service } from 'fhir-react';
import { service } from './fhir';

import { aiQuestionnaireBuilderUrl } from 'shared/src/constants';

Expand Down
2 changes: 1 addition & 1 deletion web/src/services/extract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Bundle, Questionnaire, QuestionnaireResponse, Parameters, FhirResource } from 'fhir/r4b';
import _ from 'lodash';

import { service } from 'fhir-react/lib/services/service';
import { service } from './fhir';

import { Mapping } from 'shared/src/contrib/aidbox';

Expand Down
19 changes: 19 additions & 0 deletions web/src/services/fhir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { initServices } from '@beda.software/fhir-react';

import { baseURL } from 'shared/src/constants';

export const {
axiosInstance,
service,
setInstanceToken,
resetInstanceToken,
getFHIRResource,
getFHIRResources,
getAllFHIRResources,
saveFHIRResource,
updateFHIRResource,
createFHIRResource,
forceDeleteFHIRResource,
patchFHIRResource,
setInstanceBaseURL,
} = initServices(baseURL + '/fhir');
2 changes: 1 addition & 1 deletion web/src/services/fhirmapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Bundle, QuestionnaireResponse, StructureMap } from 'fhir/r4b';

import { service } from 'fhir-react/lib/services/service';
import { service } from './fhir';

import { fhirMappingLanguageUrl } from 'shared/src/constants';

Expand Down
3 changes: 0 additions & 3 deletions web/src/services/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { setInstanceBaseURL as setAidboxInstanceBaseURL } from 'aidbox-react/lib/services/instance';

import { setInstanceBaseURL as setFHIRInstanceBaseURL } from 'fhir-react/lib/services/instance';

import { baseURL, juteURL, fhirpathMappingUrl } from 'shared/src/constants';

setAidboxInstanceBaseURL(baseURL);
setFHIRInstanceBaseURL(`${baseURL}/fhir`);

export { baseURL, juteURL, fhirpathMappingUrl };
8 changes: 4 additions & 4 deletions web/src/services/questionnaire.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
extractBundleResources,
getFHIRResources,
getReference,
ResourcesMap,
} from 'fhir-react/lib/services/fhir';
import { SearchParams } from 'fhir-react/lib/services/search';
import { mapSuccess } from 'fhir-react/lib/services/service';
} from '@beda.software/fhir-react';
import { getFHIRResources } from './fhir';
import { SearchParams } from '@beda.software/fhir-react';
import { mapSuccess } from '@beda.software/remote-data';

import { Resource } from 'shared/src/contrib/aidbox';

Expand Down

0 comments on commit 7de1056

Please sign in to comment.