@@ -6,33 +6,34 @@ angular.module('bahmni.common.domain')
66 var conditionsToBeSaved = _ . reject ( conditions , function ( condition ) {
77 return condition . onSetDate === null || Number . isInteger ( condition . onSetDate ) ;
88 } ) ;
9-
9+
1010 var promises = [ ] ;
1111
12- _ . forEach ( conditionsToBeSaved , function ( conditionToSave ) {
13- var body = {
14- patient : patientUuid ,
15- clinicalStatus : conditionToSave . status ,
16- onsetDate : conditionToSave . onSetDate ,
17- endDate : conditionToSave . endDate ,
18- additionalDetail : conditionToSave . additionalDetail ,
19- previousVersion : conditionToSave . previousConditionUuid
20- } ;
12+ _ . forEach ( conditionsToBeSaved , function ( conditionToSave ) {
13+ var body = {
14+ patient : patientUuid ,
15+ clinicalStatus : conditionToSave . status ,
16+ onsetDate : conditionToSave . onSetDate ,
17+ endDate : conditionToSave . endDate ,
18+ additionalDetail : conditionToSave . additionalDetail ,
19+ previousVersion : conditionToSave . previousConditionUuid
20+ } ;
2121
22- if ( conditionToSave . isNonCoded && conditionToSave . conditionNonCoded ) {
23- body . condition = { nonCoded : conditionToSave . conditionNonCoded } ;
24- } else if ( conditionToSave . concept && conditionToSave . concept . uuid ) {
25- body . condition = { coded : conditionToSave . concept . uuid } ;
26- }
22+ if ( conditionToSave . isNonCoded && conditionToSave . conditionNonCoded ) {
23+ body . condition = { nonCoded : conditionToSave . conditionNonCoded } ;
24+ } else if ( conditionToSave . concept && conditionToSave . concept . uuid ) {
25+ body . condition = { coded : conditionToSave . concept . uuid } ;
26+ }
2727
28- promises . push ( $http . post ( Bahmni . Common . Constants . conditionUrl , body , {
29- withCredentials : true ,
30- headers : { "Accept" : "application/json" , "Content-Type" : "application/json" }
31- } ) ) ;
32- } ) ;
28+ promises . push ( $http . post ( Bahmni . Common . Constants . conditionUrl , body , {
29+ withCredentials : true ,
30+ headers : { "Accept" : "application/json" , "Content-Type" : "application/json" }
31+ } ) ) ;
32+ } ) ;
3333
34- return promises [ promises . length - 1 ] ;
34+ return promises [ promises . length - 1 ] ;
3535 } ;
36+
3637 this . getConditionHistory = function ( patientUuid ) {
3738 var params = {
3839 patientUuid : patientUuid ,
@@ -62,11 +63,11 @@ angular.module('bahmni.common.domain')
6263 return ( conceptUuid && conceptUuid === latestCondition . concept . uuid ) ||
6364 ( nonCoded && nonCoded === latestCondition . conditionNonCoded ) ;
6465 } ) ;
65-
66+
6667 var activeCondition = _ . find ( matchingConditions , function ( condition ) {
6768 return condition . clinicalStatus === 'ACTIVE' ;
6869 } ) ;
69-
70+
7071 return activeCondition ? new Bahmni . Common . Domain . Condition ( activeCondition ) : latestCondition ;
7172 } ;
7273 this . getConditions = function ( patientUuid ) {
0 commit comments