Skip to content

Commit

Permalink
Update aidbox types and converter
Browse files Browse the repository at this point in the history
  • Loading branch information
atuonufure committed Nov 11, 2024
1 parent 0d51238 commit b853c59
Show file tree
Hide file tree
Showing 31 changed files with 246 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "in-progress",
"id": "f0a0b4cf-ff0e-47e2-814d-3327a138653e",
"authored": "2023-04-06T02:48:17.734Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed",
"id": "16917bdf-309f-4cd7-9a8a-56a928dbedea",
"authored": "2023-04-06T02:43:39Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"id": "test-patient",
"resourceType": "Patient"
},
"subject": {
"id": "test-patient",
"resourceType": "Patient"
},
"status": "completed",
"authored": "2023-04-14T09:36:35Z",
"questionnaire": "allergies",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed",
"id": "a00b8309-f74f-462c-a7e4-64852d5bf707",
"authored": "2023-04-06T01:29:05Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed",
"id": "5d59e534-a7ce-4254-8a41-31b3895ea525",
"authored": "2023-04-06T02:39:02Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed",
"id": "3d077aed-ccd4-43d4-843e-0e2224e7571e",
"authored": "2023-04-06T01:59:41Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,9 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed"
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed",
"id": "288fd914-b836-47dd-863a-e7d86a923f28",
"authored": "2023-04-06T02:05:51Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,9 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed"
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"subject": {
"id": "683e382b-fed4-433e-9b6d-a847a7953bc0",
"resourceType": "Patient"
},
"status": "completed",
"id": "a583cc11-99c6-4719-acab-cb3fb72f5078",
"authored": "2023-04-06T02:20:25Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "in-progress",
"id": "f0a0b4cf-ff0e-47e2-814d-3327a138653e",
"authored": "2023-04-06T02:48:17.734Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed",
"id": "16917bdf-309f-4cd7-9a8a-56a928dbedea",
"authored": "2023-04-06T02:43:39Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"source": {
"reference": "Patient/test-patient"
},
"subject": {
"reference": "Patient/test-patient"
},
"status": "completed",
"authored": "2023-04-14T09:36:35Z",
"questionnaire": "allergies",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed",
"id": "a00b8309-f74f-462c-a7e4-64852d5bf707",
"authored": "2023-04-06T01:29:05Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed",
"id": "5d59e534-a7ce-4254-8a41-31b3895ea525",
"authored": "2023-04-06T02:39:02Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed",
"id": "3d077aed-ccd4-43d4-843e-0e2224e7571e",
"authored": "2023-04-06T01:59:41Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,8 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed"
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed",
"id": "288fd914-b836-47dd-863a-e7d86a923f28",
"authored": "2023-04-06T02:05:51Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed"
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
"source": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"subject": {
"reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
},
"status": "completed",
"id": "a583cc11-99c6-4719-acab-cb3fb72f5078",
"authored": "2023-04-06T02:20:25Z"
Expand Down
92 changes: 92 additions & 0 deletions sdc-qrf/src/converter/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,26 @@ export enum ExtensionIdentifier {
ItemControl = 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
SliderStepValue = 'http://hl7.org/fhir/StructureDefinition/questionnaire-sliderStepValue',
Unit = 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
UnitOption = 'http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption',
ReferenceResource = 'http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource',
EntryFormat = 'http://hl7.org/fhir/StructureDefinition/entryFormat',
ColumnSize = 'http://aidbox.io/questionnaire-itemColumnSize',
ItemMedia = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemMedia',
Regex = 'http://hl7.org/fhir/StructureDefinition/regex',
ObservationExtract = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract',
ObservationLinkPeriod = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod',
MinValue = 'http://hl7.org/fhir/StructureDefinition/minValue',
MaxValue = 'http://hl7.org/fhir/StructureDefinition/maxValue',
MinQuantity = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-minQuantity',
MaxQuantity = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-maxQuantity',
ShowOrdinalValue = 'http://aidbox.io/questionnaire-showOrdinalValue',
PreferredTerminologyServer = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-preferredTerminologyServer',
OpenLabel = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-openLabel',
BackgroundImage = 'http://aidbox.io/questionnaire-backgroundImage',
Language = 'http://hl7.org/fhir/StructureDefinition/language',
ChoiceOrientation = 'http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation',
InlineChoiceDirection = 'https://beda.software/fhir-emr-questionnaire/inline-choice-direction',
ChoiceColumns = 'http://aidbox.io/fhir/StructureDefinition/questionnaire-choiceColumns',

ItemPopulationContext = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
InitialExpression = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
Expand All @@ -22,6 +41,7 @@ export enum ExtensionIdentifier {
HelpText = 'https://beda.software/fhir-emr-questionnaire/help-text',
StopLabel = 'https://beda.software/fhir-emr-questionnaire/slider-stop-label',
Macro = 'https://beda.software/fhir-emr-questionnaire/macro',
RowsNumber = 'https://beda.software/fhir-emr-questionnaire/rows-number',
}

export type ExtensionTransformer = {
Expand Down Expand Up @@ -52,9 +72,18 @@ export const extensionTransformers: ExtensionTransformer = {
[ExtensionIdentifier.SliderStepValue]: {
path: { extension: 'valueInteger', questionnaire: 'sliderStepValue' },
},
[ExtensionIdentifier.EntryFormat]: {
path: { extension: 'valueString', questionnaire: 'entryFormat' },
},
[ExtensionIdentifier.Unit]: {
path: { extension: 'valueCoding', questionnaire: 'unit' },
},
[ExtensionIdentifier.UnitOption]: {
path: { extension: 'valueCoding', questionnaire: 'unitOption' },
},
[ExtensionIdentifier.RowsNumber]: {
path: { extension: 'valueInteger', questionnaire: 'rowsNumber' },
},
[ExtensionIdentifier.ReferenceResource]: {
transform: {
fromExtension: (extension) => {
Expand All @@ -74,6 +103,69 @@ export const extensionTransformers: ExtensionTransformer = {
},
},
},
[ExtensionIdentifier.ColumnSize]: {
path: { extension: 'valueInteger', questionnaire: 'columnSize' },
},
[ExtensionIdentifier.ItemMedia]: {
path: { extension: 'valueAttachment', questionnaire: 'itemMedia' },
},
[ExtensionIdentifier.Regex]: {
path: { extension: 'valueString', questionnaire: 'regex' },
},
[ExtensionIdentifier.ObservationExtract]: {
path: { extension: 'valueBoolean', questionnaire: 'observationExtract' },
},
[ExtensionIdentifier.ObservationLinkPeriod]: {
path: { extension: 'valueDuration', questionnaire: 'observationLinkPeriod' },
},
[ExtensionIdentifier.MinValue]: {
transform: {
fromExtension: (extension) => ({ minValue: extension }),
toExtension: (item) => item.minValue,
},
},
[ExtensionIdentifier.MaxValue]: {
transform: {
fromExtension: (extension) => ({ maxValue: extension }),
toExtension: (item) => item.maxValue,
},
},
[ExtensionIdentifier.MinQuantity]: {
transform: {
fromExtension: (extension) => ({ minQuantity: extension }),
toExtension: (item) => item.minQuantity,
},
},
[ExtensionIdentifier.MaxQuantity]: {
transform: {
fromExtension: (extension) => ({ maxQuantity: extension }),
toExtension: (item) => item.maxQuantity,
},
},
[ExtensionIdentifier.ShowOrdinalValue]: {
path: { extension: 'valueBoolean', questionnaire: 'showOrdinalValue' },
},
[ExtensionIdentifier.PreferredTerminologyServer]: {
path: { extension: 'valueUri', questionnaire: 'preferredTerminologyServer' },
},
[ExtensionIdentifier.OpenLabel]: {
path: { extension: 'valueString', questionnaire: 'openLabel' },
},
[ExtensionIdentifier.BackgroundImage]: {
path: { extension: 'valueAttachment', questionnaire: 'backgroundImage' },
},
[ExtensionIdentifier.Language]: {
path: { extension: 'valueCoding', questionnaire: 'language' },
},
[ExtensionIdentifier.ChoiceOrientation]: {
path: { extension: 'valueCode', questionnaire: 'choiceOrientation' },
},
[ExtensionIdentifier.InlineChoiceDirection]: {
path: { extension: 'valueString', questionnaire: 'choiceOrientation' },
},
[ExtensionIdentifier.ChoiceColumns]: {
path: { extension: 'valueInteger', questionnaire: 'choiceColumns' },
},

[ExtensionIdentifier.ItemPopulationContext]: {
path: { extension: 'valueExpression', questionnaire: 'itemPopulationContext' },
Expand Down
25 changes: 14 additions & 11 deletions sdc-qrf/src/converter/fceToFhir/questionnaire/processItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
QuestionnaireItemAnswerOption as FHIRQuestionnaireItemAnswerOption,
QuestionnaireItemInitial as FHIRQuestionnaireItemInitial,
} from 'fhir/r4b';
import _ from 'lodash';

import {
QuestionnaireItem as FCEQuestionnaireItem,
Expand All @@ -14,11 +15,7 @@ import {
QuestionnaireItemInitial as FCEQuestionnaireItemInitial,
} from 'shared/src/contrib/aidbox';

import {
convertFromFHIRExtension,
convertToFHIRExtension,
toFHIRReference,
} from '../../../converter';
import { convertFromFHIRExtension, convertToFHIRExtension, toFHIRReference } from '../..';

export function processItems(items: FCEQuestionnaireItem[]): FHIRQuestionnaireItem[] {
return items.map((item) => {
Expand All @@ -29,6 +26,7 @@ export function processItems(items: FCEQuestionnaireItem[]): FHIRQuestionnaireIt
.filter((ext): ext is Partial<FCEQuestionnaireItem> => ext !== undefined)
.flatMap(Object.keys);
for (const field of fieldsToOmit) {
//@ts-ignore
delete item[field];
}
item.extension = extensions.sort();
Expand Down Expand Up @@ -78,6 +76,7 @@ const convertEnableWhen = (
answerType: string,
result: FHIRQuestionnaireItemEnableWhen,
) => {
//@ts-ignore
if (answer[answerType] !== undefined) {
switch (answerType) {
case 'boolean':
Expand Down Expand Up @@ -124,22 +123,26 @@ function processAnswerOption(

const fhirOption: FHIRQuestionnaireItemAnswerOption = { ...commonOptions };

if (value?.Coding) {
if (!value) {
return fhirOption;
}

if (value.Coding) {
fhirOption.valueCoding = value.Coding;
}
if (value?.string) {
if (value.string) {
fhirOption.valueString = value.string;
}
if (value?.Reference) {
if (value.Reference) {
fhirOption.valueReference = toFHIRReference(value.Reference);
}
if (value?.date) {
if (value.date) {
fhirOption.valueDate = value.date;
}
if (value?.integer) {
if (_.isNumber(value.integer)) {
fhirOption.valueInteger = value.integer;
}
if (value?.time) {
if (value.time) {
fhirOption.valueTime = value.time;
}

Expand Down
Loading

0 comments on commit b853c59

Please sign in to comment.