Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOMED phase2 bugs #781

Merged
merged 7 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading