From db8c14e435c4a8a4817735b60eaa9c070592d4f8 Mon Sep 17 00:00:00 2001 From: khlukanets Date: Sun, 16 May 2021 12:09:21 +0300 Subject: [PATCH 1/2] Moked data bandle for saving on fhir. --- app/components/fhir-data/fhir.service.js | 31 +- app/fhir-app/fhir-app-content.controller.js | 348 +++++++++++++++++++- 2 files changed, 353 insertions(+), 26 deletions(-) diff --git a/app/components/fhir-data/fhir.service.js b/app/components/fhir-data/fhir.service.js index 56d3a9a..65cbfbf 100644 --- a/app/components/fhir-data/fhir.service.js +++ b/app/components/fhir-data/fhir.service.js @@ -570,16 +570,16 @@ fb.service('fhirService', [ /** * Create Questionnaire if it does not exist, and QuestionnaireResponse and - * its extracted observations. + * its extracted observations and conditions. * Data returned through an angular broadcast event. * @param q the Questionnaire resource * @param qr the QuestionnaireResponse resource - * @param con the QuestionnaireResponse resource * @param obsArray the array of Observations extracted from qr * @param qExists true if the questionnaire is known to exist (in which case + * @param resources the bundle with all resources * we skip the lookup) */ - thisService.createQQRObsConds = function(q, qr, con, obsArray, qExists) { + thisService.createQQRObsCond = function(q, qr, obsArray, qExists, resources) { _terminatingError = null; // Build a FHIR transaction bundle to create these resources. @@ -589,31 +589,15 @@ fb.service('fhirService', [ entry: [] }; - bundle.entry.push({ - resource: qr, - request: { - method: "POST", - url: "QuestionnaireResponse" - } - }); - - bundle.entry.push({ - resource: con, - request: { - method: "POST", - url: "Condition" - } - }); - - for (var i=0, len=obsArray.length; i Date: Mon, 17 May 2021 14:45:29 +0300 Subject: [PATCH 2/2] Remove mocked data. --- app/components/fhir-data/fhir.service.js | 14 + app/fhir-app/fhir-app-content.controller.js | 344 -------------------- 2 files changed, 14 insertions(+), 344 deletions(-) diff --git a/app/components/fhir-data/fhir.service.js b/app/components/fhir-data/fhir.service.js index 65cbfbf..126186d 100644 --- a/app/components/fhir-data/fhir.service.js +++ b/app/components/fhir-data/fhir.service.js @@ -599,6 +599,20 @@ fb.service('fhirService', [ }); }); + var hasQuestionnaireResponse = bundle.entry.some(function (item) { + return item.resource.resourceType === "QuestionnaireResponse"; + }); + + if (!hasQuestionnaireResponse) { + bundle.entry.push({ + resource: qr, + request: { + method: "POST", + url: "QuestionnaireResponse" + } + }); + } + function withQuestionnaire(q) { thisService.fhir.request({url: '', method: 'POST', headers: {'Content-Type': 'application/json'}, diff --git a/app/fhir-app/fhir-app-content.controller.js b/app/fhir-app/fhir-app-content.controller.js index ee0f442..c6a16a3 100644 --- a/app/fhir-app/fhir-app-content.controller.js +++ b/app/fhir-app/fhir-app-content.controller.js @@ -136,350 +136,6 @@ angular.module('lformsApp') }).done(function (data) { fhirService.createQQRObsCond(qData, qr, resArray, qExists, data); }); - // todo: remove mocked data - var data = { - "resourceType": "Bundle", - "id": "SDOHCC-Bundle-HungerVitalSign-Example-1", - "type": "transaction", - "entry": [ - { - "fullUrl": "http://hl7.org/fhir/us/sdoh-cc/Observation/SDOHCC-Observation-HungerVitalSign-Example-1", - "resource": { - "resourceType": "Observation", - "id": "SDOHCC-Observation-HungerVitalSign-Example-1", - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "social-history", - "display": "Social History" - } - ] - }, - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "survey", - "display": "Survey" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "88122-7" - } - ], - "text": "(I/We) worried whether (my/our) food would run out before (I/we) got money to buy more." - }, - "subject": { - "reference": "Patient/pat-53234", - "display": "COLIN ABBAS" - }, - "effectivePeriod": { - "start": "2019-08-18T12:31:35.123Z", - "end": "2020-08-18T14:31:36.456Z" - }, - "issued": "2020-08-18T15:31:38.111Z", - "valueCodeableConcept": { - "coding": [ - { - "code": "LA6729-3", - "display": "Sometimes true" - } - ], - "text": "Sometimes true" - }, - "derivedFrom": [ - { - "reference": "QuestionnaireResponse/QR-1621149062320-3-a4cfdafb19ff3" - } - ] - } - }, - { - "fullUrl": "http://hl7.org/fhir/us/sdoh-cc/Observation/SDOHCC-Observation-HungerVitalSign-Example-2", - "resource": { - "resourceType": "Observation", - "id": "SDOHCC-Observation-HungerVitalSign-Example-2", - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "social-history", - "display": "Social History" - } - ] - }, - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "survey", - "display": "Survey" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "88123-5" - } - ], - "text": "The food that (I/we) bought just didn't last, and (I/we) didn't have money to get more." - }, - "subject": { - "reference": "Patient/pat-53234", - "display": "COLIN ABBAS" - }, - "effectivePeriod": { - "start": "2019-08-18T12:31:35.123Z", - "end": "2020-08-18T14:31:36.456Z" - }, - "issued": "2020-08-18T15:31:38.111Z", - "valueCodeableConcept": { - "coding": [ - { - "code": "LA6729-3", - "display": "Sometimes true" - } - ], - "text": "Sometimes true" - }, - "derivedFrom": [ - { - "reference": "QuestionnaireResponse/QR-1621149062320-3-a4cfdafb19ff3" - } - ] - } - }, - { - "fullUrl": "http://hl7.org/fhir/us/sdoh-cc/Observation/SDOHCC-Observation-HungerVitalSign-Example-3", - "resource": { - "resourceType": "Observation", - "id": "SDOHCC-Observation-HungerVitalSign-Example-3", - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "social-history", - "display": "Social History" - } - ] - }, - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "survey", - "display": "Survey" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "88124-3" - } - ], - "text": "Food insecurity risk" - }, - "subject": { - "reference": "Patient/pat-53234", - "display": "COLIN ABBAS" - }, - "effectivePeriod": { - "start": "2019-08-18T12:31:35.123Z", - "end": "2020-08-18T14:31:36.456Z" - }, - "issued": "2020-08-18T15:31:38.111Z", - "valueCodeableConcept": { - "coding": [ - { - "code": "LA19952-3", - "display": "At risk" - } - ], - "text": "At risk" - }, - "derivedFrom": [ - { - "reference": "QuestionnaireResponse/QR-1621149062320-3-a4cfdafb19ff3" - }, - { - "reference": "Observation/SDOHCC-Observation-HungerVitalSign-Example-1" - }, - { - "reference": "Observation/SDOHCC-Observation-HungerVitalSign-Example-2" - } - ] - } - }, - { - "fullUrl": "http://hl7.org/fhir/us/sdoh-cc/Observation/SDOHCC-Observation-HungerVitalSignGroup-1", - "resource": { - "resourceType": "Observation", - "id": "SDOHCC-Observation-HungerVitalSignGroup-1", - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "88121-9" - } - ] - }, - "hasMember": [ - { - "reference": "Observation/SDOHCC-Observation-HungerVitalSign-Example-1" - }, - { - "reference": "Observation/SDOHCC-Observation-HungerVitalSign-Example-2" - }, - { - "reference": "Observation/SDOHCC-Observation-HungerVitalSign-Example-3" - } - ] - } - }, - { - "fullUrl": "http://hl7.org/fhir/us/sdoh-cc/Condition/SDOHCC-Condition-HungerVitalSign-Example-1", - "resource": { - "resourceType": "Condition", - "id": "SDOHCC-Condition-HungerVitalSign-Example-1", - "clinicalStatus": { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/condition-clinical", - "code": "active", - "display": "Active" - } - ] - }, - "verificationStatus": { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status", - "code": "confirmed", - "display": "Confirmed" - } - ] - }, - "category": [ - { - "coding": [ - { - "system": "http://hl7.org/fhir/us/core/CodeSystem/condition-category", - "code": "health-concern", - "display": "Health Concern" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "733423003" - } - ], - "text": "Food insecurity" - }, - "subject": { - "reference": "Patient/pat-53234", - "display": "COLIN ABBAS" - }, - "onsetPeriod": { - "start": "2019-08-18T12:31:35.123Z" - }, - "evidence": [ - { - "detail": [ - { - "reference": "Observation/SDOHCC-Observation-HungerVitalSign-Example-3" - } - ] - } - ] - } - }, - { - "fullUrl": "QuestionnaireResponse/QR-1621149062320-3-a4cfdafb19ff3", - "resource": { - "resourceType": "QuestionnaireResponse", - "id": "QR-1621149062320-3-a4cfdafb19ff3", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse|2.7" - ], - "tag": [ - { - "code": "lformsVersion: 28.1.4" - } - ] - }, - "status": "completed", - "subject": { - "reference": "Patient/pat-53234", - "display": "COLIN ABBAS" - }, - "authored": "2021-05-16T07:11:02.320Z", - "item": [ - { - "linkId": "/88122-7", - "text": "(I/We) worried whether (my/our) food would run out before (I/we) got money to buy more.", - "answer": [ - { - "valueCoding": { - "code": "LA6729-3", - "display": "Sometimes true" - } - } - ] - }, - { - "linkId": "/88123-5", - "text": "The food that (I/we) bought just didn't last, and (I/we) didn't have money to get more.", - "answer": [ - { - "valueCoding": { - "code": "LA6729-3", - "display": "Sometimes true" - } - } - ] - }, - { - "linkId": "/88124-3", - "text": "Food insecurity risk", - "answer": [ - { - "valueCoding": { - "code": "LA19952-3", - "display": "At risk" - } - } - ] - } - ] - } - } - ] - }; - fhirService.createQQRObsCond(qData, qr, resArray, qExists, data); };