QuestionnaireViewModel

class QuestionnaireViewModel @Inject constructor(val defaultRepository: DefaultRepository, val dispatcherProvider: DispatcherProvider, val fhirCarePlanGenerator: FhirCarePlanGenerator, val resourceDataRulesExecutor: ResourceDataRulesExecutor, val transformSupportServices: TransformSupportServices, val sharedPreferencesHelper: SharedPreferencesHelper, val fhirOperator: FhirOperator, val fhirValidatorProvider: Provider<FhirValidator>, val fhirPathDataExtractor: FhirPathDataExtractor, val configurationRegistry: ConfigurationRegistry) : ViewModel

Constructors

Link copied to clipboard
@Inject
constructor(defaultRepository: DefaultRepository, dispatcherProvider: DispatcherProvider, fhirCarePlanGenerator: FhirCarePlanGenerator, resourceDataRulesExecutor: ResourceDataRulesExecutor, transformSupportServices: TransformSupportServices, sharedPreferencesHelper: SharedPreferencesHelper, fhirOperator: FhirOperator, fhirValidatorProvider: Provider<FhirValidator>, fhirPathDataExtractor: FhirPathDataExtractor, configurationRegistry: ConfigurationRegistry)

Types

Link copied to clipboard
object Companion

Properties

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
suspend fun addMemberToGroup(resource: Resource, memberResourceType: ResourceType?, groupIdentifier: String?)

Adds Resource to Group.member if the member does not exist and if Resource.logicalId is NOT the same as the retrieved GroupResourceConfig.groupIdentifier (Cannot add a Group as member of itself.

Link copied to clipboard
suspend fun executeCql(subject: Resource, bundle: Bundle, questionnaire: Questionnaire, questionnaireConfig: QuestionnaireConfig? = null)
Link copied to clipboard
suspend fun generateCarePlan(subject: Resource, bundle: Bundle, questionnaireConfig: QuestionnaireConfig)

This function generates CarePlans for the QuestionnaireResponse.subject using the configured QuestionnaireConfig.planDefinitions

Link copied to clipboard
Link copied to clipboard
fun handleQuestionnaireSubmission(questionnaire: Questionnaire, currentQuestionnaireResponse: QuestionnaireResponse, questionnaireConfig: QuestionnaireConfig, actionParameters: List<ActionParameter>, context: Context, onSuccessfulSubmission: (List<IdType>, QuestionnaireResponse) -> Unit)

This function performs data extraction against the QuestionnaireResponse. All the resources generated from a successful extraction by StructureMap or definition are stored in the database. The QuestionnaireResponse is also stored in the database regardless of the outcome of ResourceMapper.extract. This function will optionally generate CarePlan using the PlanDefinition resource configured in QuestionnaireConfig.planDefinitions. The QuestionnaireConfig.eventWorkflows contains configurations to cascade update the statuses of resources to in-active (close) that are related to the current QuestionnaireResponse.subject

Link copied to clipboard
suspend fun loadResource(resourceType: ResourceType, resourceIdentifier: String): Resource?

Load Resource of type ResourceType for the provided resourceIdentifier

Link copied to clipboard
suspend fun performExtraction(extractByStructureMap: Boolean, questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse, context: Context): Bundle

Perform StructureMap or Definition based definition. The result of this function returns a Bundle that contains the resources that were generated via the ResourceMapper.extract operation otherwise returns null if an exception is encountered.

Link copied to clipboard
suspend fun populateQuestionnaire(questionnaire: Questionnaire, questionnaireConfig: QuestionnaireConfig, actionParameters: List<ActionParameter>): Pair<QuestionnaireResponse?, List<Resource>>
Link copied to clipboard
suspend fun retireUsedQuestionnaireUniqueId(questionnaireConfig: QuestionnaireConfig, questionnaireResponse: QuestionnaireResponse)
Link copied to clipboard
suspend fun retrievePopulationResources(actionParameters: List<ActionParameter>): List<Resource>

Return Resources to be used in the launch context of the questionnaire. Launch context allows information to be passed into questionnaire based on the context in which the questionnaire is being evaluated. For example, what patient, what encounter, what user, etc. is "in context" at the time the questionnaire response is being completed: https://build.fhir.org/ig/HL7/sdc/StructureDefinition-sdc-questionnaire-launchContext.html

Link copied to clipboard
suspend fun retrieveQuestionnaire(questionnaireConfig: QuestionnaireConfig): Questionnaire?

This function retrieves the Questionnaire as configured via the QuestionnaireConfig. The retrieved Questionnaire can then be pre-populated.

Link copied to clipboard
fun saveDraftQuestionnaire(questionnaireResponse: QuestionnaireResponse)

This function saves QuestionnaireResponse as draft if any of the QuestionnaireResponse.item has an answer.

Link copied to clipboard
suspend fun saveExtractedResources(bundle: Bundle, questionnaire: Questionnaire, questionnaireConfig: QuestionnaireConfig, questionnaireResponse: QuestionnaireResponse, context: Context)
Link copied to clipboard
suspend fun searchQuestionnaireResponse(resourceId: String, resourceType: ResourceType, questionnaireId: String, encounterId: String?): QuestionnaireResponse?

This function searches and returns the latest QuestionnaireResponse for the given resourceId that was extracted from the Questionnaire identified as questionnaireId. Returns null if non is found.

Link copied to clipboard

Update the current progress state of the questionnaire.

Link copied to clipboard
suspend fun softDeleteResources(questionnaireConfig: QuestionnaireConfig)

This function triggers removal of Resource s as per the QuestionnaireConfig.groupResource or QuestionnaireConfig.removeResource config properties.

Link copied to clipboard

This function updates the _lastUpdated property of resources configured by the ActionParameter.paramType of ActionParameterType.UPDATE_DATE_ON_EDIT. Each time a questionnaire is submitted, the affected resources last modified/updated date will also be updated.

Link copied to clipboard
suspend fun validateQuestionnaireResponse(questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse, context: Context): Boolean

This function validates all QuestionnaireResponse and returns true if all the validation result of QuestionnaireResponseValidator are Valid or NotValidated (validation is optional on Questionnaire fields)

Link copied to clipboard
suspend fun validateWithFhirValidator(vararg resource: Resource)