Skip to content

Commit

Permalink
#69 Restore functionality of the SDC-IDE fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ialakey committed Jul 1, 2024
1 parent d511874 commit 85729f8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 44 deletions.
6 changes: 3 additions & 3 deletions web/src/components/ModalExpression/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useService } from '@beda.software/fhir-react';
import { isSuccess } from '@beda.software/remote-data';
import fhirpath from 'fhirpath';
import yaml from 'js-yaml';
import { useCallback, useContext, useEffect, useState } from 'react';
import { extractParameterName } from 'web/src/components/ModalExpression/utils';
import { ExpressionResultOutput } from 'web/src/containers/Main/types';
import { service } from 'web/src/services/fhir';
import YAML, { visitor } from 'yaml';

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
7 changes: 3 additions & 4 deletions web/src/components/ResourceSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { RenderRemoteData, WithId } from '@beda.software/fhir-react';
import { mapSuccess, isSuccess, RemoteData } from '@beda.software/remote-data';
import classNames from 'classnames';
import { Bundle, Resource } from 'fhir/r4b';
import _ from 'lodash';
import { useCallback } from 'react';
import { MultiValue, SingleValue } from 'react-select';

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

import s from './ResourceSelect.module.scss';
import { AsyncSelect } from '../Select';
Expand Down
7 changes: 3 additions & 4 deletions web/src/components/SourceQueryDebugModal/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useService, formatError } from '@beda.software/fhir-react';
import { isFailure, success, isSuccess, mapSuccess } from '@beda.software/remote-data';
import { Questionnaire, Bundle, Resource } from 'fhir/r4b';
import * as _ from 'lodash';
import { useCallback, useState } from 'react';
import { toast } from 'react-toastify';

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 { saveFHIRResource, service } from 'web/src/services/fhir';

import { Props } from './types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Questionnaire } from 'fhir/r4b';

import { useService, extractBundleResources } from '@beda.software/fhir-react';
import { getFHIRResources } from 'src/services/fhir';
import { mapSuccess } from '@beda.software/remote-data';
import { Questionnaire } from 'fhir/r4b';
import { getFHIRResources } from 'web/src/services/fhir';

export function useQuestionnaireEditor() {
const [questionnairesRD] = useService(async () =>
Expand Down
18 changes: 10 additions & 8 deletions web/src/containers/Main/context.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { RemoteDataResult } from '@beda.software/remote-data';
import { Parameters, Questionnaire, QuestionnaireResponse } from 'fhir/r4b';
import { createContext } from 'react';
import { QRFormWrapper } from 'web/src/components/QRFormWrapper';
import { RemoteDataResult } from '@beda.software/remote-data';
import { assemble, populate } from 'web/src/services/sdc';

import { Parameters, Questionnaire, QuestionnaireResponse } from "fhir/r4b";
import { QRFWrapper } from './types';
import { assemble, populate } from 'src/services/sdc';

type AssembleService = (qId:string) => Promise<RemoteDataResult<Questionnaire>>
type PopulateService = (launchContext:Parameters) => Promise<RemoteDataResult<QuestionnaireResponse>>
type AssembleService = (qId: string) => Promise<RemoteDataResult<Questionnaire>>;
type PopulateService = (
launchContext: Parameters,
) => Promise<RemoteDataResult<QuestionnaireResponse>>;

interface SDCContextType {
assemble: AssembleService
populate: PopulateService
assemble: AssembleService;
populate: PopulateService;
}

export const FormRenderContext = createContext<QRFWrapper>(QRFormWrapper);
export const SDCContext = createContext<SDCContextType>({ assemble, populate })
export const SDCContext = createContext<SDCContextType>({ assemble, populate });
39 changes: 17 additions & 22 deletions web/src/containers/Main/useMain.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
import { useService, WithId , formatError } from '@beda.software/fhir-react';
import {
Questionnaire,
Parameters,
ParametersParameter,
Bundle,
FhirResource,
} from 'fhir/r4b';
RemoteData,
RemoteDataResult,
failure,
isFailure,
isSuccess,
notAsked,
success,
} from '@beda.software/remote-data';
import { Questionnaire, Parameters, ParametersParameter, Bundle, FhirResource } from 'fhir/r4b';
import { useCallback, useContext, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import { generateMappingService, generateQuestionnaireService } from 'web/src/services/builder';
import { applyMapping as applyMappingService, extract } from 'web/src/services/extract';
import { service, saveFHIRResource } from 'web/src/services/fhir';

import {
createFHIRResource as createAidboxFHIRResource,
getFHIRResource as getAidboxFHIRResource,
saveFHIRResource as saveAidboxFHIRResource,
} from 'aidbox-react/lib/services/fhir';

import { useService, WithId } from '@beda.software/fhir-react';
import {
RemoteData,
RemoteDataResult,
failure,
isFailure,
isSuccess,
notAsked,
success,
} 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';

import { getMappings, makeMappingExtension } from './utils';
import { SDCContext } from './context';
import { getMappings, makeMappingExtension } from './utils';

export function useLaunchContext() {
const [launchContext, setLaunchContext] = useState<Parameters>({
Expand Down Expand Up @@ -65,7 +58,7 @@ export function useLaunchContext() {

export function useMain(questionnaireId: string) {
const navigate = useNavigate();
const {assemble, populate} = useContext(SDCContext)
const { assemble, populate } = useContext(SDCContext);
const { launchContext, setLaunchContext, clearLaunchContext } = useLaunchContext();

const [mappingRD, setMappingRD] = useState<RemoteData<WithId<Mapping>>>(notAsked);
Expand Down Expand Up @@ -107,7 +100,8 @@ export function useMain(questionnaireId: string) {

const [assembledQuestionnaireRD, assembledQuestionnaireRDManager] = useService(
() => assemble(questionnaireId),
[questionnaireId, assemble]);
[questionnaireId, assemble],
);

const reloadQuestionnaire = useCallback(async () => {
originalQuestionnaireRDManager.reload();
Expand Down Expand Up @@ -178,7 +172,8 @@ export function useMain(questionnaireId: string) {

const [questionnaireResponseRD, questionnaireResponseRDManager] = useService(
() => populate(launchContext),
[launchContext, populate]);
[launchContext, populate],
);

const createMapping = useCallback(
async (mapping: Mapping) => {
Expand Down

0 comments on commit 85729f8

Please sign in to comment.