Skip to content

Commit

Permalink
SNOMED phase2 bugs (Bahmni#781)
Browse files Browse the repository at this point in the history
* BS-281 | CDSS Observations for all the interactions (Bahmni#770)

* BS-281 | Patrick | Hide alerts for inactive diagnoses and conditions

* BS-281 | Patrick | Keep CDSS alerts for diagnosis closed after saving

* BS-281 | Patrick | Add max width  to CDSS alert popup

* BS-281 | CDSS Observations for all the interactions (Bahmni#773)

* BS-281 | Patrick | Fix order set alert tooltip text wrap

* BS-281 | Patrick | Get alerts after encounter save

* BS-281 | Patrick | Fix line height and alert spacing for the CDSS alerts

* BS-281 | Patrick | Fix saved diagnosis padding (Bahmni#774)

* Bug bash issue 4 8 (Bahmni#775)

* Bugbash issue 4 and 8

* updated test cases

* updated test cases

* BS 290 Dosage Validation (Bahmni#777)

* BS-290 | Mani | Added route information in Draft medications

* BS-290 | Mani | updated alert type

* BS 292 -  Filter only FHIR Export tasks in Admin FHIR Export UI (Bahmni#779)

* BS-292| Vijay,Siva | Filter FHIR Export Tasks

* BS-292| Vijay,Siva | Unit testcase - Filter FHIR Export Tasks

* BS-292 | Vijay,Siva | refactor name

* Vijay | Corrected README discrepancy (Bahmni#780)

---------

Co-authored-by: Patrick Nyatindo <nyatindopatrick@gmail.com>
Co-authored-by: manimaarans <110804183+manimaarans@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 17, 2023
1 parent 31ddb63 commit b380aaa
Show file tree
Hide file tree
Showing 18 changed files with 543 additions and 50 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,4 @@ This behaviour can be prevented by:
### SNOMED Integration Support

openmrs-module-bahmniapps also integrates with SNOMED for terminology lookup and CDSS. More details can be found in [this](https://bahmni.atlassian.net/wiki/spaces/BAH/pages/3132686337/SNOMED+FHIR+Terminology+Server+Integration+with+Bahmni) Wiki link
=======
> The same is already done [here](https://github.com/Bahmni/openmrs-module-bahmniapps/blob/master/package/docker/httpd.conf#L32)
openmrs-module-bahmniapps also integrates with SNOMED for terminology lookup and CDSS. More details can be found in [this](https://bahmni.atlassian.net/wiki/spaces/BAH/pages/3132686337/SNOMED+FHIR+Terminology+Server+Integration+with+Bahmni) Wiki link
11 changes: 9 additions & 2 deletions ui/app/admin/controllers/fhirExportController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,20 @@ angular.module('bahmni.admin')
var deferred = $q.defer();
$scope.tasks = [];
if (isUserPrivilegedForFhirExport()) {
fhirExportService.getUuidForAnonymiseConcept().then(function (response) {
$scope.uuid = response && response.data && response.data.results && response.data.results[0] && response.data.results[0].uuid || null;
});
fhirExportService.loadFhirTasks().then(function (response) {
if (response.data && response.data.entry) {
response.data.entry.map(function (task) {
var fhirExportTasks = response.data.entry.filter(function (task) {
return task.resource.basedOn && task.resource.basedOn.some(function (basedOn) {
return basedOn.reference === $scope.uuid;
});
});
$scope.tasks = fhirExportTasks.map(function (task) {
task.resource.authoredOn = convertToLocalDate(task.resource.authoredOn);
return task;
});
$scope.tasks = response.data.entry;
deferred.resolve();
}
}).catch(function (error) {
Expand Down
9 changes: 9 additions & 0 deletions ui/app/admin/services/fhirExportService.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ angular.module('bahmni.admin')
return DateUtil.getDateTimeInSpecifiedFormat(localDate, 'MMMM Do, YYYY [at] h:mm:ss A');
};

this.getUuidForAnonymiseConcept = function () {
const params = {
name: 'FHIR Export Anonymise Flag',
s: 'default',
v: 'default'
};
return $http.get(Bahmni.Common.Constants.conceptUrl, {params: params});
};

this.loadFhirTasks = function () {
const params = {
"_sort:desc": "_lastUpdated",
Expand Down
42 changes: 35 additions & 7 deletions ui/app/clinical/common/services/cdssService.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ angular.module('bahmni.clinical')
"code": medication.drug.uuid
}
}
]
],
"route": {
"coding": [{
"system": conceptSource,
"code": "",
"display": medication.route
}
],
"text": medication.route
}
}
]

Expand Down Expand Up @@ -242,18 +251,30 @@ angular.module('bahmni.clinical')

var getAlertMedicationCodes = function (alert) {
if (alert.referenceMedications) {
return alert.referenceMedications.map(function (med) {
return med.coding[0].code;
var codeList = [];
alert.referenceMedications.forEach(function (med) {
var extractedCodes = med.coding.map(function (coding) {
return coding.code;
});
codeList = codeList.concat(extractedCodes);
});
return codeList;
}
return [];
};

var getAlertConditionCodes = function (alert) {
if (alert.referenceCondition) {
return alert.referenceCondition.coding.map(function (cond) {
return cond.code;
if (alert.referenceConditions) {
var codeList = [];
alert.referenceConditions.forEach(function (med) {
var extractedCodes = med.coding.filter(function (cond) {
return !localStorage.getItem("conceptSource") || cond.system.includes(localStorage.getItem("conceptSource"));
}).map(function (coding) {
return coding.code;
});
codeList = codeList.concat(extractedCodes);
});
return codeList;
}
return [];
};
Expand Down Expand Up @@ -313,7 +334,9 @@ angular.module('bahmni.clinical')
return currentAlert.uuid === alert.uuid;
});
if (getAlert) {
if (alert.indicator !== getAlert.indicator || alert.summary !== getAlert.summary) {
if (alert.indicator !== getAlert.indicator || (alert.alertType === "High Dosage" && alert.summary.match(/\d+/g).sort().join('') !== getAlert.summary.match(/\d+/g).sort().join(''))) {
alert.isActive = true;
} else if (!isSubset(getAlertConditionCodes(getAlert), getAlertConditionCodes(alert)) || !isSubset(getAlertMedicationCodes(getAlert), getAlertMedicationCodes(alert))) {
alert.isActive = true;
} else {
alert.isActive = getAlert.isActive;
Expand All @@ -324,6 +347,11 @@ angular.module('bahmni.clinical')

return alerts;
};
var isSubset = function (oldList, newList) {
return newList.every(function (newItem) {
return oldList.includes(newItem);
});
};

var sortInteractionsByStatus = function (alerts) {
var order = { "critical": 0, "warning": 1, "info": 2 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ angular.module('bahmni.clinical')
$scope.addForm.$dirty = false;
});

var postSave = $rootScope.$on('event:save-successful', function () {
getAlerts();
});

$scope.$on('$destroy', function () {
postSave();
});

var markVariable = function (variable) {
$scope[variable] = true;
$timeout(function () {
Expand Down
20 changes: 12 additions & 8 deletions ui/app/clinical/consultation/controllers/consultationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ angular.module('bahmni.clinical').controller('ConsultationController',
return $q.when({});
}
try {
var alerts = $rootScope.cdssAlerts || [];
var alerts = angular.copy($rootScope.cdssAlerts) || [];
var activeAlerts = alerts.filter(function (alert) {
return alert.indicator === 'critical' && alert.isActive;
});
Expand All @@ -525,13 +525,15 @@ angular.module('bahmni.clinical').controller('ConsultationController',
return $q.when({});
}

var cdssAlerts = $rootScope.cdssAlerts;
cdssAlerts && cdssAlerts.forEach(
function (cdssAlert) {
cdssAlert.isActive = false;
}
);
$rootScope.cdssAlerts = cdssAlerts;
if (alerts && alerts.length > 0) {
var cdssAlerts = alerts.map(
function (cdssAlert) {
cdssAlert.isActive = false;
return cdssAlert;
}
);
$rootScope.cdssAlerts = cdssAlerts;
}
preSaveEvents();
return spinner.forPromise($q.all([preSavePromise(),
encounterService.getEncounterType($state.params.programUuid, sessionService.getLoginLocationUuid())]).then(function (results) {
Expand Down Expand Up @@ -571,6 +573,8 @@ angular.module('bahmni.clinical').controller('ConsultationController',
notify: true,
reload: (toStateConfig !== undefined)
});
}).then(function () {
$rootScope.$broadcast('event:save-successful');
});
}));
}).catch(function (error) {
Expand Down
47 changes: 32 additions & 15 deletions ui/app/clinical/consultation/controllers/diagnosisController.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ angular.module('bahmni.clinical')
if (pastDiagnoses && pastDiagnoses.length > 0) {
pastDiagnoses.forEach(function (diagnosis) {
diagnosis.alerts = alerts.filter(function (cdssAlert) {
return cdssAlert.referenceCondition && cdssAlert.referenceCondition.coding.some(function (coding) {
var findMapping = diagnosis.codedAnswer.mappings.find(function (mapping) {
return mapping.code === coding.code;
return cdssAlert.referenceConditions && cdssAlert.referenceConditions.some(function (referenceCondition) {
return referenceCondition.coding.some(function (coding) {
return diagnosis.codedAnswer.mappings.some(function (mapping) {
return mapping.code === coding.code;
});
});
return findMapping !== undefined;
});
});
if (diagnosis.alerts) {
Expand All @@ -131,11 +132,12 @@ angular.module('bahmni.clinical')
if (diagnoses && diagnoses.length > 0 && alerts) {
diagnoses.forEach(function (diagnosis) {
diagnosis.alerts = alerts.filter(function (cdssAlert) {
return cdssAlert.referenceCondition && cdssAlert.referenceCondition.coding.some(function (coding) {
var findMapping = diagnosis.codedAnswer.mappings.find(function (mapping) {
return mapping.code === coding.code;
return cdssAlert.referenceConditions && cdssAlert.referenceConditions.some(function (referenceCondition) {
return referenceCondition.coding.some(function (coding) {
return diagnosis.codedAnswer.mappings.some(function (mapping) {
return mapping.code === coding.code;
});
});
return findMapping !== undefined;
});
});
if (diagnosis.alerts) {
Expand All @@ -152,8 +154,10 @@ angular.module('bahmni.clinical')
if (diagnoses && diagnoses.length > 0 && alerts) {
diagnoses.forEach(function (diagnosis) {
diagnosis.alerts = alerts.filter(function (cdssAlert) {
return cdssAlert.referenceCondition && cdssAlert.referenceCondition.coding.some(function (coding) {
return diagnosis.codedAnswer.uuid === coding.code;
return cdssAlert.referenceConditions && cdssAlert.referenceConditions.some(function (referenceCondition) {
return referenceCondition.coding.some(function (coding) {
return diagnosis.codedAnswer.uuid === coding.code;
});
});
});
if (diagnosis.alerts) {
Expand All @@ -173,8 +177,10 @@ angular.module('bahmni.clinical')
condition.alerts = [];
} else if (condition && condition.concept && condition.concept.uuid && alerts) {
condition.alerts = alerts.filter(function (cdssAlert) {
return cdssAlert.referenceCondition && cdssAlert.referenceCondition.coding.some(function (coding) {
return condition.concept.uuid.includes(coding.code);
return cdssAlert.referenceConditions && cdssAlert.referenceConditions.some(function (referenceCondition) {
return referenceCondition.coding.some(function (coding) {
return condition.concept.uuid.includes(coding.code);
});
});
});
if (condition.alerts) {
Expand All @@ -192,8 +198,10 @@ angular.module('bahmni.clinical')
if (conditions && conditions.length > 0 && alerts) {
conditions.forEach(function (condition) {
condition.alerts = alerts.filter(function (cdssAlert) {
return cdssAlert.referenceCondition && cdssAlert.referenceCondition.coding.some(function (coding) {
return condition.concept.uuid.includes(coding.code);
return cdssAlert.referenceConditions && cdssAlert.referenceConditions.some(function (referenceCondition) {
return referenceCondition.coding.some(function (coding) {
return condition.concept.uuid.includes(coding.code);
});
});
});
if (condition.alerts) {
Expand All @@ -218,6 +226,14 @@ angular.module('bahmni.clinical')
alertsWatch();
});

var postSave = $rootScope.$on('event:save-successful', function () {
getAlerts();
});

$scope.$on('$destroy', function () {
postSave();
});

var addPlaceHolderDiagnosis = function () {
var diagnosis = new Bahmni.Common.Domain.Diagnosis('');
$scope.consultation.newlyAddedDiagnoses.push(diagnosis);
Expand Down Expand Up @@ -403,6 +419,7 @@ angular.module('bahmni.clinical')
}
condition.voided = false;
updateOrAddCondition(new Bahmni.Common.Domain.Condition(condition));
getConditionsAlerts();
};
$scope.markAs = function (condition, status) {
condition.status = status;
Expand Down Expand Up @@ -481,7 +498,7 @@ angular.module('bahmni.clinical')
diagnosisService.deleteDiagnosis(obsUUid).then(function () {
messagingService.showMessage('info', 'DELETED_MESSAGE');
var currentUuid = $scope.consultation.savedDiagnosesFromCurrentEncounter.length > 0
? $scope.consultation.savedDiagnosesFromCurrentEncounter[0].encounterUuid : "";
? $scope.consultation.savedDiagnosesFromCurrentEncounter[0].encounterUuid : "";
getAlerts();
return reloadDiagnosesSection(currentUuid);
}));
Expand Down
2 changes: 1 addition & 1 deletion ui/app/clinical/consultation/views/cdssAlertRow.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div>
<div class="summary">
<p ng-class="{'strike-text': !alert.isActive}">
<b ng-if="alert.alertType === 'High Dosage'">{{alert.alertType}}: </b>
<b ng-if="alert.alertType === 'High Dosage' || alert.alertType === 'Validation Error'">{{alert.alertType}}: </b>
{{alert.summary}}</p>
</div>
<div
Expand Down
2 changes: 1 addition & 1 deletion ui/app/clinical/consultation/views/cdssPopover.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ "DISMISSED_KEY" | translate}} {{alert.indicator}}
</div>
<p>
<b ng-if="alert.alertType === 'High Dosage'">{{alert.alertType}}: </b>
<b ng-if="alert.alertType === 'High Dosage' || alert.alertType === 'Validation Error'">{{alert.alertType}}: </b>
{{alert.summary}}
</p>
<div class="alert-detail">
Expand Down
4 changes: 2 additions & 2 deletions ui/app/clinical/consultation/views/conditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="col col1" bm-pop-over autoclose="true">
<div class="col-header">{{'CONDITION_LIST_CONDITION'|translate}}</div>
<div class="col-body">
<span ng-if="consultation.condition.alerts && consultation.condition.alerts.length > 0 && !hasActiveAlerts(consultation.condition.alerts)" class="alert-item">
<span ng-if="consultation.condition.alerts && consultation.condition.alerts.length > 0 && !hasActiveAlerts(consultation.condition.alerts) && (!consultation.condition.status || consultation.condition.status === 'ACTIVE')" class="alert-item">
<button class="cdss-alert-icon button-alert alert-button" bm-pop-over-trigger>
<i class="fa cdss-icon-medication fa-exclamation-circle">
</i>
Expand Down Expand Up @@ -69,7 +69,7 @@
<textarea class="comment-section" maxlength="255" ng-model="consultation.condition.additionalDetail">
</textarea>
</div>
<div class="row" ng-if="hasActiveAlerts(consultation.condition.alerts)" ng-repeat="alert in consultation.condition.alerts">
<div class="row" ng-if="hasActiveAlerts(consultation.condition.alerts) && (!consultation.condition.status || consultation.condition.status === 'ACTIVE')" ng-repeat="alert in consultation.condition.alerts">
<ng-include class="new-diagnosis-alert-row" src="'consultation/views/diagnosisAlertRow.html'" />
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions ui/app/clinical/consultation/views/diagnosis.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{ ::'CLINICAL_DIAGNOSIS' | translate }}
</div>
<div class="col-body">
<span ng-if="diagnosis.alerts && diagnosis.alerts.length > 0 && !hasActiveAlerts(diagnosis.alerts)" class="alert-item">
<span ng-if="diagnosis.alerts && diagnosis.alerts.length > 0 && !hasActiveAlerts(diagnosis.alerts) && (!diagnosis.diagnosisStatus || diagnosis.status === 'ACTIVE')" class="alert-item">
<button class="cdss-alert-icon button-alert alert-button" bm-pop-over-trigger>
<i class="fa cdss-icon-medication fa-exclamation-circle">
</i>
Expand Down Expand Up @@ -91,7 +91,7 @@
</div>
</div>
</div>
<div class="row" ng-if="hasActiveAlerts(diagnosis.alerts)" ng-repeat="alert in diagnosis.alerts">
<div class="row" ng-if="hasActiveAlerts(diagnosis.alerts) && (!diagnosis.diagnosisStatus || diagnosis.diagnosisStatus === 'ACTIVE')" ng-repeat="alert in diagnosis.alerts">
<ng-include class="new-diagnosis-alert-row" src="'consultation/views/diagnosisAlertRow.html'" />
</div>
<div class="col col-comments" ng-show="diagnosis.showComments">
Expand Down Expand Up @@ -129,7 +129,7 @@ <h2 class="section-title">{{ ::'CLINICAL_CURRENT' | translate }}</h2>
<div class="col col3"><span>{{ ::'CLINICAL_CURRENT' | translate }}</span></div>
<div class="col col4" ng-if="pastDiagnosesAlerts">
<div class="cdss-alert-icon header-alert-icon">
<i class="fa fa-exclamation-triangle"></i>
<i class="fa fa-exclamation-circle"></i>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit b380aaa

Please sign in to comment.