Skip to content

Commit

Permalink
Merge pull request #373 from beda-software/move-convertors
Browse files Browse the repository at this point in the history
Use convertors from sdc qrf
  • Loading branch information
vesnushka authored Nov 18, 2024
2 parents 36af841 + e4f85cd commit 8e3f3b9
Show file tree
Hide file tree
Showing 110 changed files with 75 additions and 13,926 deletions.
3 changes: 0 additions & 3 deletions contrib/aidbox-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14137,9 +14137,6 @@ export interface QuestionnaireItem {
/** NOTE: from extension http://hl7.org/fhir/StructureDefinition/questionnaire-constraint */
/** An invariant that must be satisfied before responses to the questionnaire can be considered "complete". */
constraint?: QuestionnaireItemConstraint[];
/** NOTE: from extension http://hl7.org/fhir/StructureDefinition/cqf-expression */
/** An expression that, when evaluated, provides the value for the element on which it appears. */
cqfExpression?: Expression;
/** ElementDefinition - details for the item */
definition?: uri;
/** all | any */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"react-select": "^5.7.3",
"recharts": "^2.12.0",
"sass": "^1.63.6",
"sdc-qrf": "0.3.4",
"sdc-qrf": "^0.3.8",
"styled-components": "^6.1.11",
"yup": "^1.2.0"
},
Expand Down
57 changes: 57 additions & 0 deletions resources/seeds/Questionnaire/cqf-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

name: CQF Examples
title: CQF Examples
subjectType:
- Encounter
- Patient
item:
- text: Click on this checkbox to see result
type: boolean
linkId: input-1
- text: This is default input label
type: string
_text:
cqfExpression:
language: text/fhirpath
expression: >-
iif(%QuestionnaireResponse.item.where(linkId='input-1').answer.value.boolean
= true, 'Now the input label changed', null)
linkId: input-2
- item:
- text: This input is disabled if the checkbox is unchecked
type: string
linkId: input-5
readOnly: true
_readOnly:
cqfExpression:
language: text/fhirpath
expression: >-
%QuestionnaireResponse.item.where(linkId='input-1').answer.value.boolean
= false
- text: This input is required if the checkbox is checked
type: string
linkId: input-6
required: false
_required:
cqfExpression:
language: text/fhirpath
expression: >-
%QuestionnaireResponse.item.where(linkId='input-1').answer.value.boolean
= true
text: This is default group label
type: group
_text:
cqfExpression:
language: text/fhirpath
expression: >-
iif(%QuestionnaireResponse.item.where(linkId='input-1').answer.value.boolean
= true, 'Now the group label changed', null)
linkId: input-3
resourceType: Questionnaire
status: active
id: cqf-examples
meta:
profile:
- https://beda.software/beda-emr-questionnaire
url: >-
https://aidbox.emr.beda.software/ui/console#/entities/Questionnaire/cqf-examples
3 changes: 1 addition & 2 deletions src/__tests__/fce.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { Questionnaire as FCEQuestionnaire } from '@beda.software/aidbox-types';

import { getFHIRResource } from 'src/services/fhir';
import { loginAdminUser } from 'src/setupTests';
import { toFirstClassExtension, fromFirstClassExtension } from 'src/utils/converter';
import { sortExtensionsList } from 'src/utils/converter/__tests__/fce.test';
import { fromFirstClassExtension, sortExtensionsList, toFirstClassExtension } from 'sdc-qrf';

describe('Questionanire and QuestionnaireResponses transformation', () => {
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ResourceTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { RenderRemoteData, SearchParams, extractBundleResources, ResourcesMap }
import { Spinner } from 'src/components/Spinner';
import { Table } from 'src/components/Table';
import { usePagerExtended } from 'src/hooks/pager';
import { fromFHIRReference } from 'src/utils/converter';
import { fromFHIRReference } from 'sdc-qrf';

type GetTableColumns<R> = (provenanceList: Provenance[]) => ColumnsType<R>;

Expand Down
2 changes: 1 addition & 1 deletion src/containers/PatientDetails/DocumentHistory/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isSuccess, mapSuccess, resolveMap } from '@beda.software/remote-data';
import { getFHIRResource } from 'src/services/fhir';
import { loadResourceHistory } from 'src/services/history';
import { getProvenanceByEntity } from 'src/services/provenance';
import { fromFirstClassExtension, toFirstClassExtension } from 'src/utils/converter';
import { fromFirstClassExtension, toFirstClassExtension } from 'sdc-qrf';

export function useDocumentHistory() {
const params = useParams<{ qrId: string }>();
Expand Down
2 changes: 1 addition & 1 deletion src/containers/PatientDetails/DocumentHistory/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { findAnswersForQuestionsRecursive, mapResponseToForm } from 'sdc-qrf/lib

import { AidboxReference } from '@beda.software/aidbox-types';

import { toFirstClassExtension } from 'src/utils/converter';
import { getDisplay } from 'src/utils/questionnaire';
import { toFirstClassExtension } from 'sdc-qrf';

export function findResourceInHistory<R extends Resource>(provenanceRef: AidboxReference, history: R[]) {
const [resourceType, id, , versionId] = (provenanceRef.uri || '').split('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
QuestionnaireResponseItem,
} from '@beda.software/aidbox-types';

import { toFirstClassExtension } from 'src/utils/converter';
import { getDisplay } from 'src/utils/questionnaire';
import { getExternalQuestionnaireName } from 'src/utils/smart-apps';

import { S } from './ExternalDocumentView.styles';
import { toFirstClassExtension } from 'sdc-qrf';

interface Props {
questionnaireResponse: FHIRQuestionnaireResponse;
Expand Down
2 changes: 1 addition & 1 deletion src/containers/PatientDetails/PatientOrders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Modal } from 'src/components/Modal';
import { QuestionnaireResponseForm } from 'src/components/QuestionnaireResponseForm';
import { ResourceTable, LinkToEdit } from 'src/components/ResourceTable';
import { questionnaireIdLoader } from 'src/hooks/questionnaire-response-form-data';
import { extractExtension } from 'src/utils/converter';
import { formatHumanDate } from 'src/utils/date';
import { selectCurrentUserRoleResource } from 'src/utils/role';
import { extractExtension } from 'sdc-qrf';

const { Search } = Input;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Resource, Provenance } from 'fhir/r4b';
import { Link, useLocation } from 'react-router-dom';

import { fromFHIRReference } from 'src/utils/converter';
import { fromFHIRReference } from 'sdc-qrf';

export function LinkToEdit(props: { name?: string; resource: Resource; provenanceList: Provenance[] }) {
const { name, resource, provenanceList } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { PatientActivitySummary } from 'src/containers/PatientDetails/PatientAct
import { LinkToEdit } from 'src/containers/PatientDetails/PatientOverviewDynamic/components/LinkToEdit';
import { OverviewCard } from 'src/containers/PatientDetails/PatientOverviewDynamic/components/StandardCard/types';
import medicationIcon from 'src/containers/PatientDetails/PatientOverviewDynamic/images/medication.svg';
import { extractExtension, fromFHIRReference } from 'src/utils/converter';
import { formatHumanDate } from 'src/utils/date';
import { extractExtension, fromFHIRReference } from 'sdc-qrf';

export function prepareAllergies(
allergies: AllergyIntolerance[],
Expand Down
2 changes: 1 addition & 1 deletion src/containers/PatientDetails/PatientResources/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
import { WithId } from '@beda.software/fhir-react';

import { ResourceTable, Option, LinkToEdit } from 'src/components/ResourceTable';
import { extractExtension } from 'src/utils/converter';
import { formatHumanDate, formatHumanDateTime } from 'src/utils/date';
import { extractExtension } from 'sdc-qrf';

export function getOptions(patient: WithId<Patient>): Option[] {
return [
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Prescriptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { RenderRemoteData } from '@beda.software/fhir-react';

import { PageContainer } from 'src/components/PageContainer';
import { Spinner } from 'src/components/Spinner';
import { extractExtension } from 'src/utils/converter';
import { formatHumanDate } from 'src/utils/date';
import { renderHumanName } from 'src/utils/fhir';
import { matchCurrentUserRole, Role, selectCurrentUserRoleResource } from 'src/utils/role';
Expand All @@ -17,6 +16,7 @@ import { useMedicationRequest } from './hooks';
import { ModalMedicationRequestCancel } from './ModalMedicationRequestCancel';
import { ModalMedicationRequestConfirm } from './ModalMedicationRequestConfirm';
import { getSelectedValue } from '../OrganizationScheduling/utils';
import { extractExtension } from 'sdc-qrf';

export function Prescriptions() {
const {
Expand Down
3 changes: 1 addition & 2 deletions src/containers/QuestionnaireBuilder/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { Questionnaire as FHIRQuestionnaire, QuestionnaireItem as FHIRQuestionna
import _ from 'lodash';
import { useCallback, useEffect, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { GroupItemProps, QuestionItemProps } from 'sdc-qrf';
import { fromFirstClassExtension, GroupItemProps, QuestionItemProps, toFirstClassExtension } from 'sdc-qrf';

import { formatError } from '@beda.software/fhir-react';
import { RemoteData, isFailure, isSuccess, loading, notAsked, success } from '@beda.software/remote-data';

import { getFHIRResource, saveFHIRResource } from 'src/services/fhir';
import { generateQuestionnaire, generateQuestionnaireFromFile } from 'src/services/questionnaire-builder';
import { fromFirstClassExtension, toFirstClassExtension } from 'src/utils/converter';

import { deleteQuestionnaireItem, getQuestionPath, moveQuestionnaireItem } from './utils';

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/questionnaire-response-form-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
QuestionnaireResponseFormData,
calcInitialContext,
removeDisabledAnswers,
toFirstClassExtension,
fromFirstClassExtension,
} from 'sdc-qrf';

import {
Expand All @@ -27,8 +29,6 @@ import { RemoteDataResult, isFailure, isSuccess, mapSuccess, success } from '@be

import { saveFHIRResource, service } from 'src/services/fhir';

import { toFirstClassExtension, fromFirstClassExtension } from '../utils/converter';

export type { QuestionnaireResponseFormData } from 'sdc-qrf';

export type QuestionnaireResponseFormSaveResponse<R extends Resource = any> = {
Expand Down
Loading

0 comments on commit 8e3f3b9

Please sign in to comment.