2 lines
33 KiB
JavaScript
2 lines
33 KiB
JavaScript
"use strict";angular.module("bahmni.common.conceptSet").factory("formService",["$http",function($http){var getFormList=function(encounterUuid){return $http.get(Bahmni.Common.Constants.latestPublishedForms,{params:{encounterUuid:encounterUuid}})},getAllForms=function(){return $http.get(Bahmni.Common.Constants.allFormsUrl,{params:{v:"custom:(version,name,uuid)"}})},getFormDetail=function(formUuid,params){return $http.get(Bahmni.Common.Constants.formUrl+"/"+formUuid,{params:params})},getFormTranslations=function(url,form){return url&&url!==Bahmni.Common.Constants.formTranslationsUrl?$http.get(url):$http.get(Bahmni.Common.Constants.formTranslationsUrl,{params:form})};return{getFormList:getFormList,getAllForms:getAllForms,getFormDetail:getFormDetail,getFormTranslations:getFormTranslations}}]),angular.module("bahmni.common.domain").service("visitService",["$http",function($http){this.getVisit=function(uuid,params){var parameters=params?params:"custom:(uuid,visitId,visitType,patient,encounters:(uuid,encounterType,voided,orders:(uuid,orderType,voided,concept:(uuid,set,name),),obs:(uuid,value,concept,obsDatetime,groupMembers:(uuid,concept:(uuid,name),obsDatetime,value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name)))))))";return $http.get(Bahmni.Common.Constants.visitUrl+"/"+uuid,{params:{v:parameters}})},this.endVisit=function(visitUuid){return $http.post(Bahmni.Common.Constants.endVisitUrl+"?visitUuid="+visitUuid,{withCredentials:!0})},this.endVisitAndCreateEncounter=function(visitUuid,bahmniEncounterTransaction){return $http.post(Bahmni.Common.Constants.endVisitAndCreateEncounterUrl+"?visitUuid="+visitUuid,bahmniEncounterTransaction,{withCredentials:!0})},this.updateVisit=function(visitUuid,attributes){return $http.post(Bahmni.Common.Constants.visitUrl+"/"+visitUuid,attributes,{withCredentials:!0})},this.createVisit=function(visitDetails){return $http.post(Bahmni.Common.Constants.visitUrl,visitDetails,{withCredentials:!0})},this.getVisitSummary=function(visitUuid){return $http.get(Bahmni.Common.Constants.visitSummaryUrl,{params:{visitUuid:visitUuid},withCredentials:!0})},this.search=function(parameters){return $http.get(Bahmni.Common.Constants.visitUrl,{params:parameters,withCredentials:!0})},this.getVisitType=function(){return $http.get(Bahmni.Common.Constants.visitTypeUrl,{withCredentials:!0})}}]),angular.module("bahmni.common.domain").service("diagnosisService",["$http","$rootScope",function($http,$rootScope){var self=this;this.getAllFor=function(searchTerm){var url=Bahmni.Common.Constants.emrapiConceptUrl;return $http.get(url,{params:{term:searchTerm,limit:20}})},this.getDiagnoses=function(patientUuid,visitUuid){var url=Bahmni.Common.Constants.bahmniDiagnosisUrl;return $http.get(url,{params:{patientUuid:patientUuid,visitUuid:visitUuid}})},this.deleteDiagnosis=function(obsUuid){var url=Bahmni.Common.Constants.bahmniDeleteDiagnosisUrl;return $http.get(url,{params:{obsUuid:obsUuid}})},this.getDiagnosisConceptSet=function(){return $http.get(Bahmni.Common.Constants.conceptUrl,{method:"GET",params:{v:"custom:(uuid,name,setMembers)",code:Bahmni.Common.Constants.diagnosisConceptSet,source:Bahmni.Common.Constants.emrapiConceptMappingSource},withCredentials:!0})},this.getPastAndCurrentDiagnoses=function(patientUuid,encounterUuid){return self.getDiagnoses(patientUuid).then(function(response){var diagnosisMapper=new Bahmni.DiagnosisMapper($rootScope.diagnosisStatus),allDiagnoses=diagnosisMapper.mapDiagnoses(response.data),pastDiagnoses=diagnosisMapper.mapPastDiagnosis(allDiagnoses,encounterUuid),savedDiagnosesFromCurrentEncounter=diagnosisMapper.mapSavedDiagnosesFromCurrentEncounter(allDiagnoses,encounterUuid);return{pastDiagnoses:pastDiagnoses,savedDiagnosesFromCurrentEncounter:savedDiagnosesFromCurrentEncounter}})},this.populateDiagnosisInformation=function(patientUuid,consultation){return this.getPastAndCurrentDiagnoses(patientUuid,consultation.encounterUuid).then(function(diagnosis){return consultation.pastDiagnoses=diagnosis.pastDiagnoses,consultation.savedDiagnosesFromCurrentEncounter=diagnosis.savedDiagnosesFromCurrentEncounter,consultation})}}]),angular.module("bahmni.common.domain").service("conditionsService",["$http",function($http){this.save=function(conditions,patientUuid){var body=_.map(conditions,function(condition){return{uuid:condition.uuid,patientUuid:patientUuid,concept:condition.concept,conditionNonCoded:condition.conditionNonCoded,status:condition.status,onSetDate:condition.onSetDate,endDate:condition.endDate,endReason:condition.endReason,additionalDetail:condition.additionalDetail,voided:condition.voided,voidReason:condition.voidReason}});return $http.post(Bahmni.Common.Constants.conditionUrl,body,{withCredentials:!0,headers:{Accept:"application/json","Content-Type":"application/json"}})},this.getConditionHistory=function(patientUuid){var params={patientUuid:patientUuid};return $http.get(Bahmni.Common.Constants.conditionHistoryUrl,{params:params,headers:{withCredentials:!0}})},this.getFollowUpConditionConcept=function(){return $http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{params:{name:Bahmni.Common.Constants.followUpConditionConcept,v:"custom:(uuid,name:(name))"},cache:!0})};var getLatestActiveCondition=function(conditionHistories,latestCondition){var conditionHistory=_.find(conditionHistories,{conceptUuid:latestCondition.concept.uuid,conditionNonCoded:latestCondition.conditionNonCoded});return Bahmni.Common.Domain.Conditions.getPreviousActiveCondition(latestCondition,conditionHistory.conditions)};this.getConditions=function(patientUuid){return this.getConditionHistory(patientUuid).then(function(response){var conditionHistories=response.data,conditions=Bahmni.Common.Domain.Conditions.fromConditionHistories(conditionHistories);return _.forEach(conditions,function(condition){condition.activeSince=getLatestActiveCondition(conditionHistories,condition).onSetDate}),conditions})}}]),angular.module("bahmni.common.orders").service("orderTypeService",["$http",function($http){var self=this;self.orderTypes=[],self.loadAll=function(){return $http.get("/openmrs/ws/rest/v1/ordertype",{params:{v:"custom:(uuid,display,conceptClasses:(uuid,display,name))"}}).then(function(response){return self.orderTypes=response.data.results,self.orderTypes})},self.getOrderTypeUuid=function(orderTypeName){return _.result(_.find(self.orderTypes,{display:orderTypeName}),"uuid")}}]),angular.module("bahmni.common.patient").service("patientService",["$http","sessionService",function($http,sessionService){this.getPatient=function(uuid){var patient=$http.get(Bahmni.Common.Constants.openmrsUrl+"/ws/rest/v1/patient/"+uuid,{method:"GET",params:{v:"full"},withCredentials:!0});return patient},this.getRelationships=function(patientUuid){return $http.get(Bahmni.Common.Constants.openmrsUrl+"/ws/rest/v1/relationship",{method:"GET",params:{person:patientUuid,v:"full"},withCredentials:!0})},this.findPatients=function(params){return $http.get(Bahmni.Common.Constants.sqlUrl,{method:"GET",params:params,withCredentials:!0})},this.search=function(query,offset,identifier){return offset=offset||0,$http.get(Bahmni.Common.Constants.bahmniSearchUrl+"/patient",{method:"GET",params:{q:query,startIndex:offset,identifier:identifier,loginLocationUuid:sessionService.getLoginLocationUuid()},withCredentials:!0})},this.getPatientContext=function(patientUuid,programUuid,personAttributes,programAttributes,patientIdentifiers){return $http.get("/openmrs/ws/rest/v1/bahmnicore/patientcontext",{params:{patientUuid:patientUuid,programUuid:programUuid,personAttributes:personAttributes,programAttributes:programAttributes,patientIdentifiers:patientIdentifiers},withCredentials:!0})}}]),angular.module("bahmni.common.domain").factory("locationService",["$http","$bahmniCookieStore",function($http,$bahmniCookieStore){var getAllByTag=function(tags,operator){return $http.get(Bahmni.Common.Constants.locationUrl,{params:{s:"byTags",tags:tags||"",v:"default",operator:operator||"ALL"},cache:!0})},getByUuid=function(locationUuid){return $http.get(Bahmni.Common.Constants.locationUrl+"/"+locationUuid,{cache:!0}).then(function(response){return response.data})},getLoggedInLocation=function(){var cookie=$bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName);return getByUuid(cookie.uuid)},getVisitLocation=function(locationUuid){return $http.get(Bahmni.Common.Constants.bahmniVisitLocationUrl+"/"+locationUuid,{headers:{Accept:"application/json"}})};return{getAllByTag:getAllByTag,getLoggedInLocation:getLoggedInLocation,getByUuid:getByUuid,getVisitLocation:getVisitLocation}}]),angular.module("bahmni.clinical").factory("labOrderResultService",["$http","$q","configurationService",function($http,$q,configurationService){var allTestsAndPanelsConcept={};configurationService.getConfigurations(["allTestsAndPanelsConcept"]).then(function(configurations){allTestsAndPanelsConcept=configurations.allTestsAndPanelsConcept.results[0]});var sanitizeData=function(labOrderResults){labOrderResults.forEach(function(result){result.accessionDateTime=Bahmni.Common.Util.DateUtil.parse(result.accessionDateTime),result.hasRange=result.minNormal&&result.maxNormal})},groupByPanel=function(accessions){var grouped=[];return accessions.forEach(function(labOrders){var panels={},accessionGroup=[];labOrders.forEach(function(labOrder){labOrder.panelName?(panels[labOrder.panelName]=panels[labOrder.panelName]||{accessionDateTime:labOrder.accessionDateTime,orderName:labOrder.panelName,tests:[],isPanel:!0},panels[labOrder.panelName].tests.push(labOrder)):(labOrder.isPanel=!1,labOrder.orderName=labOrder.testName,accessionGroup.push(labOrder))}),_.values(panels).forEach(function(val){accessionGroup.push(val)}),grouped.push(accessionGroup)}),grouped},flattened=function(accessions){return accessions.map(function(results){var flattenedResults=_(results).map(function(result){return result.isPanel===!0?[result,result.tests]:result}).flattenDeep().value();return flattenedResults})},transformGroupSort=function(results,initialAccessionCount,latestAccessionCount){var labOrderResults=results.results;sanitizeData(labOrderResults);var accessionConfig={initialAccessionCount:initialAccessionCount,latestAccessionCount:latestAccessionCount},tabularResult=new Bahmni.Clinical.TabularLabOrderResults(results.tabularResult,accessionConfig),accessions=_.groupBy(labOrderResults,function(labOrderResult){return labOrderResult.accessionUuid});if(accessions=_.sortBy(accessions,function(accession){return accession[0].accessionDateTime}),accessionConfig.initialAccessionCount||accessionConfig.latestAccessionCount){var initial=_.take(accessions,accessionConfig.initialAccessionCount||0),latest=_.takeRight(accessions,accessionConfig.latestAccessionCount||0);accessions=_.union(initial,latest)}return accessions.reverse(),{accessions:groupByPanel(accessions),tabularResult:tabularResult}},getAllForPatient=function(params){var deferred=$q.defer(),paramsToBeSent={};return params.visitUuids?paramsToBeSent.visitUuids=params.visitUuids:(params.patientUuid||deferred.reject("patient uuid is mandatory"),paramsToBeSent.patientUuid=params.patientUuid,0!==params.numberOfVisits&&(paramsToBeSent.numberOfVisits=params.numberOfVisits)),$http.get(Bahmni.Common.Constants.bahmniLabOrderResultsUrl,{method:"GET",params:paramsToBeSent,withCredentials:!0}).then(function(response){var results=transformGroupSort(response.data,params.initialAccessionCount,params.latestAccessionCount),sortedConceptSet=new Bahmni.Clinical.ConceptWeightBasedSorter(allTestsAndPanelsConcept),resultObject={labAccessions:flattened(results.accessions.map(sortedConceptSet.sortTestResults)),tabular:results.tabularResult};resultObject.tabular.tabularResult.orders=sortedConceptSet.sortTestResults(resultObject.tabular.tabularResult.orders),deferred.resolve(resultObject)}),deferred.promise};return{getAllForPatient:getAllForPatient}}]),angular.module("bahmni.common.domain").factory("configurationService",["$http","$q",function($http,$q){var configurationFunctions={};configurationFunctions.encounterConfig=function(){return $http.get(Bahmni.Common.Constants.encounterConfigurationUrl,{params:{callerContext:"REGISTRATION_CONCEPTS"},withCredentials:!0})},configurationFunctions.patientConfig=function(){var patientConfig=$http.get(Bahmni.Common.Constants.patientConfigurationUrl,{withCredentials:!0});return patientConfig},configurationFunctions.patientAttributesConfig=function(){return $http.get(Bahmni.Common.Constants.personAttributeTypeUrl,{params:{v:"custom:(uuid,name,sortWeight,description,format,concept)"},withCredentials:!0})},configurationFunctions.dosageFrequencyConfig=function(){var dosageFrequencyConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.dosageFrequencyConceptName},withCredentials:!0});return dosageFrequencyConfig},configurationFunctions.dosageInstructionConfig=function(){var dosageInstructionConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.dosageInstructionConceptName},withCredentials:!0});return dosageInstructionConfig},configurationFunctions.stoppedOrderReasonConfig=function(){var stoppedOrderReasonConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.stoppedOrderReasonConceptName},withCredentials:!0});return stoppedOrderReasonConfig},configurationFunctions.consultationNoteConfig=function(){var consultationNoteConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.consultationNoteConceptName},withCredentials:!0});return consultationNoteConfig},configurationFunctions.radiologyObservationConfig=function(){var radiologyObservationConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name)",name:Bahmni.Common.Constants.radiologyResultConceptName},withCredentials:!0});return radiologyObservationConfig},configurationFunctions.labOrderNotesConfig=function(){var labOrderNotesConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name)",name:Bahmni.Common.Constants.labOrderNotesConcept},withCredentials:!0});return labOrderNotesConfig},configurationFunctions.defaultEncounterType=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{params:{property:"bahmni.encounterType.default"},withCredentials:!0,transformResponse:[function(data){return data}]})},configurationFunctions.radiologyImpressionConfig=function(){var radiologyImpressionConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name)",name:Bahmni.Common.Constants.impressionConcept},withCredentials:!0});return radiologyImpressionConfig},configurationFunctions.addressLevels=function(){return $http.get(Bahmni.Common.Constants.openmrsUrl+"/module/addresshierarchy/ajax/getOrderedAddressHierarchyLevels.form",{withCredentials:!0})},configurationFunctions.allTestsAndPanelsConcept=function(){var allTestsAndPanelsConcept=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name:(uuid,name),setMembers:(uuid,name:(uuid,name)))",name:Bahmni.Common.Constants.allTestsAndPanelsConceptName},withCredentials:!0});return allTestsAndPanelsConcept},configurationFunctions.identifierTypesConfig=function(){return $http.get(Bahmni.Common.Constants.idgenConfigurationURL,{withCredentials:!0})},configurationFunctions.genderMap=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"mrs.genders"},withCredentials:!0})},configurationFunctions.relationshipTypeMap=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"bahmni.relationshipTypeMap"},withCredentials:!0})},configurationFunctions.relationshipTypeConfig=function(){return $http.get(Bahmni.Common.Constants.relationshipTypesUrl,{withCredentials:!0,params:{v:"custom:(aIsToB,bIsToA,uuid)"}})},configurationFunctions.loginLocationToVisitTypeMapping=function(){var url=Bahmni.Common.Constants.entityMappingUrl;return $http.get(url,{params:{mappingType:"loginlocation_visittype",s:"byEntityAndMappingType"}})},configurationFunctions.enableAuditLog=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"bahmni.enableAuditLog"},withCredentials:!0})};var existingPromises={},configurations={},getConfigurations=function(configurationNames){var configurationsPromiseDefer=$q.defer(),promises=[];return configurationNames.forEach(function(configurationName){existingPromises[configurationName]||(existingPromises[configurationName]=configurationFunctions[configurationName]().then(function(response){configurations[configurationName]=response.data}),promises.push(existingPromises[configurationName]))}),$q.all(promises).then(function(){configurationsPromiseDefer.resolve(configurations)}),configurationsPromiseDefer.promise};return{getConfigurations:getConfigurations}}]),angular.module("bahmni.common.appFramework").service("loadConfigService",["$http",function($http){this.loadConfig=function(url){return $http.get(url,{withCredentials:!0})}}]),angular.module("bahmni.common.domain").service("encounterService",["$http","$q","$rootScope","configurations","$bahmniCookieStore",function($http,$q,$rootScope,configurations,$bahmniCookieStore){function isObsConceptClassVideoOrImage(obs){return"Video"===obs.concept.conceptClass||"Image"===obs.concept.conceptClass}this.buildEncounter=function(encounter){encounter.observations=encounter.observations||[],encounter.observations.forEach(function(obs){stripExtraConceptInfo(obs)}),encounter.providers=encounter.providers||[];var providerData=$bahmniCookieStore.get(Bahmni.Common.Constants.grantProviderAccessDataCookieName);return _.isEmpty(encounter.providers)&&(providerData&&providerData.uuid?encounter.providers.push({uuid:providerData.uuid}):$rootScope.currentProvider&&$rootScope.currentProvider.uuid&&encounter.providers.push({uuid:$rootScope.currentProvider.uuid})),encounter};var getDefaultEncounterType=function(){var url=Bahmni.Common.Constants.encounterTypeUrl;return $http.get(url+"/"+configurations.defaultEncounterType()).then(function(response){return response.data})},getEncounterTypeBasedOnLoginLocation=function(loginLocationUuid){return $http.get(Bahmni.Common.Constants.entityMappingUrl,{params:{entityUuid:loginLocationUuid,mappingType:"location_encountertype",s:"byEntityAndMappingType"},withCredentials:!0})},getEncounterTypeBasedOnProgramUuid=function(programUuid){return $http.get(Bahmni.Common.Constants.entityMappingUrl,{params:{entityUuid:programUuid,mappingType:"program_encountertype",s:"byEntityAndMappingType"},withCredentials:!0})},getDefaultEncounterTypeIfMappingNotFound=function(entityMappings){var encounterType=entityMappings.data.results[0]&&entityMappings.data.results[0].mappings[0];return encounterType||(encounterType=getDefaultEncounterType()),encounterType};this.getEncounterType=function(programUuid,loginLocationUuid){return programUuid?getEncounterTypeBasedOnProgramUuid(programUuid).then(function(response){return getDefaultEncounterTypeIfMappingNotFound(response)}):loginLocationUuid?getEncounterTypeBasedOnLoginLocation(loginLocationUuid).then(function(response){return getDefaultEncounterTypeIfMappingNotFound(response)}):getDefaultEncounterType()},this.create=function(encounter){return encounter=this.buildEncounter(encounter),$http.post(Bahmni.Common.Constants.bahmniEncounterUrl,encounter,{withCredentials:!0})},this["delete"]=function(encounterUuid,reason){return $http["delete"](Bahmni.Common.Constants.bahmniEncounterUrl+"/"+encounterUuid,{params:{reason:reason}})};var deleteIfImageOrVideoObsIsVoided=function(obs){if(obs.voided&&obs.groupMembers&&!obs.groupMembers.length&&obs.value&&isObsConceptClassVideoOrImage(obs)){var url=Bahmni.Common.Constants.RESTWS_V1+"/bahmnicore/visitDocument?filename="+obs.value;$http["delete"](url,{withCredentials:!0})}},stripExtraConceptInfo=function(obs){deleteIfImageOrVideoObsIsVoided(obs),obs.concept={uuid:obs.concept.uuid,name:obs.concept.name,dataType:obs.concept.dataType},obs.groupMembers=obs.groupMembers||[],obs.groupMembers.forEach(function(groupMember){stripExtraConceptInfo(groupMember)})},searchWithoutEncounterDate=function(visitUuid){return $http.post(Bahmni.Common.Constants.bahmniEncounterUrl+"/find",{visitUuids:[visitUuid],includeAll:Bahmni.Common.Constants.includeAllObservations},{withCredentials:!0})};this.search=function(visitUuid,encounterDate){return encounterDate?$http.get(Bahmni.Common.Constants.emrEncounterUrl,{params:{visitUuid:visitUuid,encounterDate:encounterDate,includeAll:Bahmni.Common.Constants.includeAllObservations},withCredentials:!0}):searchWithoutEncounterDate(visitUuid)},this.find=function(params){return $http.post(Bahmni.Common.Constants.bahmniEncounterUrl+"/find",params,{withCredentials:!0})},this.findByEncounterUuid=function(encounterUuid){return $http.get(Bahmni.Common.Constants.bahmniEncounterUrl+"/"+encounterUuid,{params:{includeAll:!0},withCredentials:!0})},this.getEncountersForEncounterType=function(patientUuid,encounterTypeUuid){return $http.get(Bahmni.Common.Constants.encounterUrl,{params:{patient:patientUuid,encounterType:encounterTypeUuid,v:"custom:(uuid,provider,visit:(uuid,startDatetime,stopDatetime),obs:(uuid,concept:(uuid,name),groupMembers:(id,uuid,obsDatetime,value,comment)))"},withCredentials:!0})},this.getDigitized=function(patientUuid){var patientDocumentEncounterTypeUuid=configurations.encounterConfig().getPatientDocumentEncounterTypeUuid();return $http.get(Bahmni.Common.Constants.encounterUrl,{params:{patient:patientUuid,encounterType:patientDocumentEncounterTypeUuid,v:"custom:(uuid,obs:(uuid))"},withCredentials:!0})},this.discharge=function(encounterData){var encounter=this.buildEncounter(encounterData);return $http.post(Bahmni.Common.Constants.dischargeUrl,encounter,{withCredentials:!0})}}]),angular.module("bahmni.clinical").service("diseaseTemplateService",["$http","$q","clinicalAppConfigService",function($http,$q,clinicalAppConfigService){this.getLatestDiseaseTemplates=function(patientUuid,diseaseTemplates,startDate,endDate){var url=Bahmni.Common.Constants.diseaseTemplateUrl,params={patientUuid:patientUuid,diseaseTemplateConfigList:diseaseTemplates};params.startDate=startDate&&moment(startDate).format(Bahmni.Common.Constants.ServerDateTimeFormat),params.endDate=endDate&&moment(endDate).format(Bahmni.Common.Constants.ServerDateTimeFormat);var deferred=$q.defer();return $http.post(url,params,{withCredentials:!0,headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(response){var diseaseTemplates=mapDiseaseTemplates(response.data,clinicalAppConfigService.getAllConceptsConfig());deferred.resolve(diseaseTemplates)}),deferred.promise},this.getAllDiseaseTemplateObs=function(patientUuid,diseaseName,startDate,endDate){var url=Bahmni.Common.Constants.AllDiseaseTemplateUrl,params={patientUuid:patientUuid,diseaseTemplateConfigList:[{templateName:diseaseName}]};params.startDate=startDate&&moment(startDate).format(Bahmni.Common.Constants.ServerDateTimeFormat),params.endDate=endDate&&moment(endDate).format(Bahmni.Common.Constants.ServerDateTimeFormat);var deferred=$q.defer();return $http.post(url,params,{withCredentials:!0,headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(diseaseTemplateResponse){var diseaseTemplates=mapDiseaseTemplates([diseaseTemplateResponse.data],clinicalAppConfigService.getAllConceptsConfig());deferred.resolve(diseaseTemplates[0])}),deferred.promise};var mapDiseaseTemplates=function(diseaseTemplates,allConceptsConfig){var mappedDiseaseTemplates=[];return diseaseTemplates.forEach(function(diseaseTemplate){mappedDiseaseTemplates.push(new Bahmni.Clinical.DiseaseTemplateMapper(diseaseTemplate,allConceptsConfig))}),mappedDiseaseTemplates}}]),angular.module("bahmni.common.domain").service("observationsService",["$http",function($http){this.fetch=function(patientUuid,conceptNames,scope,numberOfVisits,visitUuid,obsIgnoreList,filterObsWithOrders,patientProgramUuid){var params={concept:conceptNames};return obsIgnoreList&&(params.obsIgnoreList=obsIgnoreList),null!=filterObsWithOrders&&(params.filterObsWithOrders=filterObsWithOrders),visitUuid?(params.visitUuid=visitUuid,params.scope=scope):(params.patientUuid=patientUuid,params.numberOfVisits=numberOfVisits,params.scope=scope,params.patientProgramUuid=patientProgramUuid),$http.get(Bahmni.Common.Constants.observationsUrl,{params:params,withCredentials:!0})},this.getByUuid=function(observationUuid){return $http.get(Bahmni.Common.Constants.observationsUrl,{params:{observationUuid:observationUuid},withCredentials:!0})},this.getRevisedObsByUuid=function(observationUuid){return $http.get(Bahmni.Common.Constants.observationsUrl,{params:{observationUuid:observationUuid,revision:"latest"},withCredentials:!0})},this.fetchForEncounter=function(encounterUuid,conceptNames){return $http.get(Bahmni.Common.Constants.observationsUrl,{params:{encounterUuid:encounterUuid,concept:conceptNames},withCredentials:!0})},this.fetchForPatientProgram=function(patientProgramUuid,conceptNames,scope,obsIgnoreList){return $http.get(Bahmni.Common.Constants.observationsUrl,{params:{patientProgramUuid:patientProgramUuid,concept:conceptNames,scope:scope,obsIgnoreList:obsIgnoreList},withCredentials:!0})},this.getObsRelationship=function(targetObsUuid){return $http.get(Bahmni.Common.Constants.obsRelationshipUrl,{params:{targetObsUuid:targetObsUuid},withCredentials:!0})},this.getObsInFlowSheet=function(patientUuid,conceptSet,groupByConcept,orderByConcept,conceptNames,numberOfVisits,initialCount,latestCount,groovyExtension,startDate,endDate,patientProgramUuid){var params={patientUuid:patientUuid,conceptSet:conceptSet,groupByConcept:groupByConcept,orderByConcept:orderByConcept,conceptNames:conceptNames,numberOfVisits:numberOfVisits,initialCount:initialCount,latestCount:latestCount,name:groovyExtension,startDate:Bahmni.Common.Util.DateUtil.parseLongDateToServerFormat(startDate),endDate:Bahmni.Common.Util.DateUtil.parseLongDateToServerFormat(endDate),enrollment:patientProgramUuid};return $http.get(Bahmni.Common.Constants.observationsUrl+"/flowSheet",{params:params,withCredentials:!0})}}]),angular.module("bahmni.common.conceptSet").factory("conceptSetService",["$http","$q","$bahmniTranslate",function($http,$q,$bahmniTranslate){var getConcept=function(params,cache){return params.locale=params.locale||$bahmniTranslate.use(),$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{params:params,cache:cache})},getComputedValue=function(encounterData){var url=Bahmni.Common.Constants.encounterModifierUrl;return $http.post(url,encounterData,{withCredentials:!0,headers:{Accept:"application/json","Content-Type":"application/json"}})},getObsTemplatesForProgram=function(programUuid){var url=Bahmni.Common.Constants.entityMappingUrl;return $http.get(url,{params:{entityUuid:programUuid,mappingType:"program_obstemplate",s:"byEntityAndMappingType"}})};return{getConcept:getConcept,getComputedValue:getComputedValue,getObsTemplatesForProgram:getObsTemplatesForProgram}}]),Bahmni.Common.Util.DateTimeFormatter={getDateWithoutTime:function(datetime){return datetime?moment(datetime).format("YYYY-MM-DD"):null}},angular.module("bahmni.common.logging").service("loggingService",function(){var log=function(errorDetails){$.ajax({type:"POST",url:"/log",contentType:"application/json",data:angular.toJson(errorDetails)})};return{log:log}}),angular.module("bahmni.common.logging").service("auditLogService",["$http","$translate","configurationService",function($http,$translate,configurationService){var DateUtil=Bahmni.Common.Util.DateUtil,convertToLocalDate=function(date){var localDate=DateUtil.parseLongDateToServerFormat(date);return DateUtil.getDateTimeInSpecifiedFormat(localDate,"MMMM Do, YYYY [at] h:mm:ss A")};this.getLogs=function(params){return params=params||{},$http.get(Bahmni.Common.Constants.auditLogUrl,{params:params}).then(function(response){return response.data.map(function(log){log.dateCreated=convertToLocalDate(log.dateCreated);var entity=log.message?log.message.split("~")[1]:void 0;return log.params=entity?JSON.parse(entity):entity,log.message=log.message.split("~")[0],log.displayMessage=$translate.instant(log.message,log),log})})},this.log=function(patientUuid,eventType,messageParams,module){return configurationService.getConfigurations(["enableAuditLog"]).then(function(result){if(result.enableAuditLog){var params={};return params.patientUuid=patientUuid,params.eventType=Bahmni.Common.AuditLogEventDetails[eventType].eventType,params.message=Bahmni.Common.AuditLogEventDetails[eventType].message,params.message=messageParams?params.message+"~"+JSON.stringify(messageParams):params.message,params.module=module,$http.post(Bahmni.Common.Constants.auditLogUrl,params,{withCredentials:!0})}})}}]),angular.module("bahmni.clinical").factory("treatmentService",["$http","$q","appService",function($http,$q,appService){var createDrugOrder=function(drugOrder){return Bahmni.Clinical.DrugOrder.create(drugOrder)},getActiveDrugOrdersFromServer=function(patientUuid,startDate,endDate){return $http.get(Bahmni.Common.Constants.bahmniDrugOrderUrl+"/active",{params:{patientUuid:patientUuid,startDate:startDate,endDate:endDate},withCredentials:!0})},getPrescribedAndActiveDrugOrders=function(patientUuid,numberOfVisits,getOtherActive,visitUuids,startDate,endDate,getEffectiveOrdersOnly){return $http.get(Bahmni.Common.Constants.bahmniDrugOrderUrl+"/prescribedAndActive",{params:{patientUuid:patientUuid,numberOfVisits:numberOfVisits,getOtherActive:getOtherActive,visitUuids:visitUuids,startDate:startDate,endDate:endDate,getEffectiveOrdersOnly:getEffectiveOrdersOnly},withCredentials:!0}).success(function(response){for(var key in response)response[key]=response[key].map(createDrugOrder)})},getConfig=function(){return $http.get(Bahmni.Common.Constants.drugOrderConfigurationUrl,{withCredentials:!0})},getProgramConfig=function(){var programConfig=appService.getAppDescriptor()?appService.getAppDescriptor().getConfigValue("program")||{}:{};return programConfig},getActiveDrugOrders=function(patientUuid,fromDate,toDate){var programConfig=getProgramConfig(),startDate=programConfig.showDetailsWithinDateRange?fromDate:null,endDate=programConfig.showDetailsWithinDateRange?toDate:null,deferred=$q.defer();return getActiveDrugOrdersFromServer(patientUuid,startDate,endDate).success(function(response){var activeDrugOrders=response.map(createDrugOrder);deferred.resolve(activeDrugOrders)}),deferred.promise},getPrescribedDrugOrders=function(patientUuid,includeActiveVisit,numberOfVisits,fromDate,toDate){var programConfig=getProgramConfig(),startDate=programConfig.showDetailsWithinDateRange?fromDate:null,endDate=programConfig.showDetailsWithinDateRange?toDate:null,deferred=$q.defer();return $http.get(Bahmni.Common.Constants.bahmniDrugOrderUrl,{method:"GET",params:{patientUuid:patientUuid,numberOfVisits:numberOfVisits,includeActiveVisit:includeActiveVisit,startDate:startDate,endDate:endDate},withCredentials:!0}).success(function(response){var activeDrugOrders=response.map(createDrugOrder);deferred.resolve(activeDrugOrders)}),deferred.promise},getNonCodedDrugConcept=function(){var deferred=$q.defer();return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"drugOrder.drugOther"},withCredentials:!0,headers:{Accept:"text/plain"}}).success(function(conceptUuid){deferred.resolve(conceptUuid)}),deferred.promise},getAllDrugOrdersFor=function(patientUuid,conceptSetToBeIncluded,conceptSetToBeExcluded,isActive,patientProgramUuid){var deferred=$q.defer(),params={
|
|
patientUuid:patientUuid};return conceptSetToBeIncluded&&(params.includeConceptSet=conceptSetToBeIncluded),conceptSetToBeExcluded&&(params.excludeConceptSet=conceptSetToBeExcluded),void 0!==isActive&&(params.isActive=isActive),patientProgramUuid&&(params.patientProgramUuid=patientProgramUuid),$http.get(Bahmni.Common.Constants.bahmniDrugOrderUrl+"/drugOrderDetails",{params:params,withCredentials:!0}).success(function(response){deferred.resolve(response)}),deferred.promise},voidDrugOrder=function(drugOrder){var deferred=$q.defer();return $http["delete"]([Bahmni.Common.Constants.ordersUrl,"/",drugOrder.uuid].join("")).success(function(response){deferred.resolve(response)}),deferred.promise};return{getActiveDrugOrders:getActiveDrugOrders,getConfig:getConfig,getPrescribedDrugOrders:getPrescribedDrugOrders,getPrescribedAndActiveDrugOrders:getPrescribedAndActiveDrugOrders,getNonCodedDrugConcept:getNonCodedDrugConcept,getAllDrugOrdersFor:getAllDrugOrdersFor,voidDrugOrder:voidDrugOrder}}]),Bahmni.Clinical.StateNameEvenTypeMap={"search.patientsearch":"VIEWED_CLINICAL_PATIENT_SEARCH","patient.dashboard.show":"VIEWED_CLINICAL_DASHBOARD","patient.dashboard.show.observations":"VIEWED_OBSERVATIONS_TAB","patient.dashboard.show.diagnosis":"VIEWED_DIAGNOSIS_TAB","patient.dashboard.show.treatment.page":"VIEWED_TREATMENT_TAB","patient.dashboard.show.disposition":"VIEWED_DISPOSITION_TAB","patient.dashboard.show.summary":"VIEWED_DASHBOARD_SUMMARY","patient.dashboard.show.orders":"VIEWED_ORDERS_TAB","patient.dashboard.show.bacteriology":"VIEWED_BACTERIOLOGY_TAB","patient.dashboard.show.investigation":"VIEWED_INVESTIGATION_TAB","patient.visit.summaryprint":"VIEWED_SUMMARY_PRINT","patient.dashboard.visit":"VIEWED_VISIT_DASHBOARD","patient.dashboard.visitPrint":"VIEWED_VISIT_PRINT","patient.dashboard.observation":"VIEWED_DASHBOARD_OBSERVATION","patient.patientProgram.show":"VIEWED_PATIENTPROGRAM"}; |