Form API
Form API
aidbox.sdc/convert-questionnaire
- converts FHIR Questionnaire to Aidbox SDC Formaidbox.sdc/convert-form
- converts Aidbox Form to FHIR Questionnaireaidbox.sdc/convert-forms
- converts Aidbox Forms to FHIR Questionnaire resourcesaidbox.sdc/generate-form-template
- genereate form from scratchaidbox.sdc/generate-form-layout
- generate form layoutaidbox.sdc/generate-form-constraints
- generate constraints schemaaidbox.sdc/generate-form-finalize
- generate finalize with extractionsaidbox.sdc/get-form-properties
- get form related propertiesaidbox.sdc/add-form-properties
- add form dynamic propertiesaidbox.sdc/delete-form-properties
- delete form dynamic propertiesaidbox.sdc/get-forms
- get existed formsaidbox.sdc/get-form
- get form definition for given form nameaidbox.sdc/launch
- launch new form with given params
Document API
aidbox.sdc/read-document
- get form with saved documentaidbox.sdc/save
- save documentaidbox.sdc/sign
- finalize document, run extractsaidbox.sdc/convert-document
- converts SDCDocument to FHIR QuestionnaireResponseaidbox.sdc/get-form-access-jwt
- creates policy token for formaidbox.sdc/generate-form-link
- creates shared form linkaidbox.sdc/amend
- put document to in-amendment state. Used for correctionsaidbox.sdc/add-note
- add note as addendum to the given document
convert-questionnaire
Converts Questionnaire to Aidbox SDC Form (Document + Form + Launch + (Finalize))
params:
Param | Description | Type | required? |
---|---|---|---|
url | Link to Questinnaire on public FHIR server | zen/string | no |
resource | Questionnaire resource body | zenbox/resource | no |
options | Additional options | map | no |
optinos.gen-extractions | Generate basic extractions for fields | boolean | no |
optinos.keygen-strategy | Strategy for document keys generation | "text"/"numbers"/"link-id"/"code-or-link-id" | no |
optinos.base-name | Name prefix for all generated zen-symbols and namespace | string | no |
options.key-prefix | Prefix for document keys | zen/string | no |
Request:
Result:
convert-form
Converts Aidbox Form to FHIR Questionnaire, optionaly can save it to Questinnaire resource in Aidbox.
As Aidbox Forms is able to express more stuff than Questionnaire can handle - only subset of Forms functionality supported for convertion.
Basically only Document
and FinalizeConstraints
DSLs are supported
What is supported:
Document
structure with questionsnested questions
repeated questions
Questions ordering based on natural question order in
Document DSL
required fields based on
Document DSL
andFinalizeConstraints DSL
Questionnaire root properties via
Forms DSL
properties
params:
Param | Description | Type | required? |
---|---|---|---|
form | Form symbolic name | string | yes |
format | Format of QR. Aidbox or FHIR | string | yes |
save-to-resource | Save Questionnaire to resource | boolean | no |
opts | Map | no | |
opts.describe-rules* | If true - will add field calculation rule description to QR | boolean | no |
to use include-scores and describe-rules options you need to import
aidbox.sdc.extra
namespace in configuration project
To save Questionnaire to resource you should specify
:fhir/id
property in theForm DSL
To specify additional fields that are represented in Questionnaire but not in the Form DSL - you can use predefined form properties for that
Form DSL
Request:
Result:
Error:
convert-forms
Convert all SDCForms with :fhir/id property to FHIR questionnaire and store them in DB.
params:
Param | Description | Type | required? |
---|---|---|---|
describe-rules* | If true - will add field calculation rule description to Q | boolean | no |
Returns list of pairs [form-name, convertions-result] where convertion result is one of:
Ok
{messge: "error message"}
Request:
Result:
generate-form-template
Generate ZEN namespace with empty Form definition and all relevant layers. You can use this as starting point when you need create custom form from scratch.
Note: rpc doesn't make any changes in filesystem - it just returns template. You then should save it to file manually
params:
Param | Description | Type | required? |
---|---|---|---|
ns | Namespace of form | String | no |
title | Form Title | String | no |
Result:
generate-form-layout
Generate Form Layout Definition, based on Document schema.
Note: rpc doesn't make any changes in filesystem - it just returns template. You then should save it to file manually
params:
Param | Description | Type | required? |
---|---|---|---|
document | SDCDocument schema name | symbol | yes |
show-keys | fields to show in layout | vector of strings | no |
if show-keys
is not given - generate layout for all fields in the document.
NOTE: layout fields order will be the same as natural keys order in SDCDocument
Result:
Error
generate-form-constraints
Generate Form FinalizeConstrains Definition, based on Document schema
Note: rpc doesn't make any changes in filesystem - it just returns template. You then should save it to file manually
params:
Param | Description | Type | required? |
---|---|---|---|
document | SDCDocument schema name | symbol | yes |
required-keys | Required fields | vector of strings | no |
if required-keys
is not given - all fields are required by default.
Result:
Error
generate-form-finalize
Generate Form Finalize Definition with extractions, based on Document schema.
Note: rpc doesn't make any changes in filesystem - it just returns template. You then should save it to file manually
params:
Param | Description | Type | required? |
---|---|---|---|
document | SDCDocument schema name | symbol | yes |
extract-keys | Keys for extraction | vector of strings | no |
profile | name of Finalize Constraint profile. | string/symbol | no |
if extract-keys
is not given - generate layout for all fields in the document.
Result:
Error
get-form-properties
Get form related properties.
Properties is a typical map where each key is a property name and value is any JSON value
Properties are stored in two sources:
in ZEN (properties of Form symbol) - static properties
in DB (SDCFormMetadata resource) - dynamic properties
You can query static
, dynamic
or all
form properties.
You can manage dynamic properties by
add-form-properties
anddelete-form-properties
RPCs
params:
Param | Description | Type | required? |
---|---|---|---|
form | Form symbolic name | String | yes |
properties | properties type | static/dynamic/all | no |
Request:
Response:
add-form-properties
Add set of dynamic properties to a form.
Properties is a typical map where each key is a property name and value is any JSON value Dynamic Properties - properties that are stored in DB, in
SDCFormMetadata
resource
Given properties will be merged with existed - you can replace old values by this operation.
Returns updated SDCFormMetadata
resource.
params:
Param | Description | Type | required? |
---|---|---|---|
form | Form symbolic name | String | yes |
properties | properties map | map | yes |
Request:
Result:
Success
delete-form-properties
Delete set of form dynamic properties.
Dynamic Properties - properties that are stored in DB, in
SDCFormMetadata
resource
Returns updated SDCFormMetadata
resource. Returns error when SDCFormMetadata
resource or some of property name is not found
params:
Param | Description | Type | required? |
---|---|---|---|
form | Form symbolic name | String | yes |
properties | properties names to delete | vector of strings | yes |
Request:
Response:
Success
Error
get-forms
Get forms definitions
Response can be narrowed with document Symbol name substring
params:
Param | Description | Type | required? |
---|---|---|---|
q | substring of Form symbolic name | String | no |
include.properties | include-filter for properties match | map | no |
exclude.properties | exclude-filter for properties match | map | no |
include/exclude filter
include/exclude properties should be in that shape as you except them in Form definition.
if property value is a set - then filter specifies elements subset with AND logic
if property value is a coll - then filter specifies collection matching with strict order and elements counts
if property value is a map - then filter specifies subset of map structure with searched leaves values
if property value is a keyword/string/symbol - then filter specifies equal match by stringified property value.
Request:
Result
get-form
Get form for given document definition
params:
Param | Description | Type | required? |
---|---|---|---|
form | Form Symbol name | String | yes |
launch
Launch form with given launch, prepoluate data, and return enriched with metadata layout.
Param | Description | Type | required? |
---|---|---|---|
form | Form Symbol name | String | yes |
dry-run | Run without saving document in db | boolean | no |
unit-system | Preffered unit system (default: imperial) |
| no |
rules-in-lisp | Return rules as Lisp or AST | boolean | no |
params | Params to launch-context | map | no |
Result:
Success
Error:
read-document
Get form for saved document.
Param | Description | Type | required? |
---|---|---|---|
id | Document id | String | yes |
rules-in-lisp | Return rules as Lisp or AST | boolean | no |
Result:
Success
Error:
save
Save document draft without Finalize Profile validations. Can be used with documents in draft
, in-progress
, in-amendment
statuses
Param | Description | Type | required? |
---|---|---|---|
document | document resource | SDCDocument | yes |
If document in draft
status - set in-progress
status to it.
Request:
Result:
Error
Success
sign
Validates document and run extractions on it. Mark document as completed.
Can be used wiht Documents in draft
, in-progress
, in-amendment
statuses.
Param | Description | Type | required? |
---|---|---|---|
document | document resource | SDCDocument | yes |
dry-run | Run without saving document and extractions | boolean | no |
Apply created
/patched
/deleted
extractions. Create Provenance
resource with links to SDCDocument
and created resources(created
extractions).
Additionally will create History SDCAddendum resource with timestamp user and document snapshot.
Additionally when called on document with
in-amendment
status it will
delete previously created extractions, Provenance resource, and recreate them with new data.
create Amendment SDCAddendum resource with timestamp, user, and diff between last two snapshots from History addendums.
Response:
Success
Error