Skip to content

Commit

Permalink
Merge pull request LHNCBC#1 from khristinalukanets/master
Browse files Browse the repository at this point in the history
Merge changes from Khrystyna
  • Loading branch information
yuflyud authored May 17, 2021
2 parents 8df8610 + 66b454b commit 4b46544
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
35 changes: 16 additions & 19 deletions app/components/fhir-data/fhir.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -589,28 +589,26 @@ fb.service('fhirService', [
entry: []
};

bundle.entry.push({
resource: qr,
request: {
method: "POST",
url: "QuestionnaireResponse"
}
resources.entry.forEach(function (item) {
bundle.entry.push({
resource: item.resource,
request: {
method: "POST",
url: item.resource.resourceType
}
});
});

bundle.entry.push({
resource: con,
request: {
method: "POST",
url: "Condition"
}
var hasQuestionnaireResponse = bundle.entry.some(function (item) {
return item.resource.resourceType === "QuestionnaireResponse";
});

for (var i=0, len=obsArray.length; i<len; ++i) {
if (!hasQuestionnaireResponse) {
bundle.entry.push({
resource: obsArray[i],
resource: qr,
request: {
method: "POST",
url: "Observation"
url: "QuestionnaireResponse"
}
});
}
Expand All @@ -621,7 +619,6 @@ fb.service('fhirService', [
body: JSON.stringify(bundle)}).then(

function success(resp) {
debugger;
_collectedResults.push(resp);
reportResults();
// Look through the bundle for the QuestionnaireResource ID
Expand Down
4 changes: 2 additions & 2 deletions app/fhir-app/fhir-app-content.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ angular.module('lformsApp')
jQuery.ajax('http://localhost:8080/administration/convert', {
method: 'POST',
crossDomain: true,
dataType: "json",
contentType: 'application/json',
data: JSON.stringify(qr)
}).done(function (data) {
// fhirService.createQQRObsConds(qData, qr, data.con, resArray, qExists);
fhirService.createQQRObsCond(qData, qr, resArray, qExists, data);
});
};

Expand Down

0 comments on commit 4b46544

Please sign in to comment.