From cba0928bd2c29fd0f32c76d9f2ab3408e9846989 Mon Sep 17 00:00:00 2001 From: Brian Postlethwaite Date: Sat, 18 May 2024 22:31:10 -0500 Subject: [PATCH] Enable the rendering of the QR into the nlm editor when coming from the forms-lab pre-pop, or from the show response in the csiro renderer --- .../EditorNLMRendererSection.vue | 21 +- .../Questionnaire/EditorRendererSection.vue | 19 +- components/QuestionnairePrepopTest.vue | 2 +- pages/Questionnaire/tester.vue | 313 ++++++------------ 4 files changed, 139 insertions(+), 216 deletions(-) diff --git a/components/Questionnaire/EditorNLMRendererSection.vue b/components/Questionnaire/EditorNLMRendererSection.vue index cae9774..ad779be 100644 --- a/components/Questionnaire/EditorNLMRendererSection.vue +++ b/components/Questionnaire/EditorNLMRendererSection.vue @@ -58,6 +58,16 @@ declare namespace LForms.Util { formId: string, options?: object ): QuestionnaireResponse; + function convertFHIRQuestionnaireToLForms( + questionnaire: Questionnaire, + fhirVersion: string + ): any; + function mergeFHIRDataIntoLForms( + resourceType: "QuestionnaireResponse", + response: QuestionnaireResponse, + lhcQ: any, + fhirVersion: string + ): any; } declare global { interface Window { @@ -113,6 +123,15 @@ export default Vue.extend({ this.$emit("response", response); }, + /** Show this QR in the display (if it wasn't generated by itself) */ + renderQuestionnaireResponse(response: QuestionnaireResponse, questionnaire: Questionnaire) { + if (!(response.meta?.tag && response.meta.tag.length > 0 && response.meta.tag[0].code?.startsWith('lformsVersion'))) { + console.log("Rendering response in lforms Renderer", response); + var lhcQ = LForms.Util.convertFHIRQuestionnaireToLForms(questionnaire, "R4"); + var lhcQR = LForms.Util.mergeFHIRDataIntoLForms("QuestionnaireResponse", response, lhcQ, "R4") + LForms.Util.addFormToPage(lhcQR, 'myFormContainer', { prepopulate: false }); + } + }, async prePopLForms(sourceFhirServer: string, subjectId: string) { console.log("Prepopulating LForms with data from", sourceFhirServer, subjectId); if (window.LForms) { @@ -125,7 +144,7 @@ export default Vue.extend({ var fhirContext = FHIR.client(setupServer); // Not sure if we should be adding others in here or not // and put the other context vars in here (such as source-query which isn't internally handled by the LForms renderer) - var fhirContextVars = { }; + var fhirContextVars = {}; LForms.Util.setFHIRContext(fhirContext, fhirContextVars); this.lforms_error = undefined; diff --git a/components/Questionnaire/EditorRendererSection.vue b/components/Questionnaire/EditorRendererSection.vue index d2ee154..06d06ed 100644 --- a/components/Questionnaire/EditorRendererSection.vue +++ b/components/Questionnaire/EditorRendererSection.vue @@ -30,8 +30,8 @@ pre {