@peopl-health/nexus 6.0.0-dev.718 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/lib/adapters/BaileysProvider.js +8 -37
- package/lib/adapters/MessageAdapter.js +3 -1
- package/lib/adapters/MessageProvider.js +0 -11
- package/lib/adapters/TwilioProvider.js +44 -77
- package/lib/clinical/AssistantProcessor.js +414 -19
- package/lib/clinical/assistants/BaseAssistant.js +0 -15
- package/lib/clinical/config/checkInConfig.js +3 -0
- package/lib/clinical/config/cohortConfig.js +3 -3
- package/lib/clinical/config/composerConfig.js +42 -0
- package/lib/clinical/config/divergenceConfig.js +80 -50
- package/lib/clinical/config/llmConfig.js +11 -2
- package/lib/clinical/config/safetyNetConfig.js +108 -0
- package/lib/clinical/config/subAgentsConfig.js +61 -2
- package/lib/clinical/context/ToolRuntimeContext.js +121 -6
- package/lib/clinical/context/turnContext.js +50 -0
- package/lib/clinical/flags/bridgeConfig.js +31 -0
- package/lib/clinical/flags/clinicalContextFlags.js +46 -0
- package/lib/clinical/flags/composerFlags.js +14 -0
- package/lib/clinical/flags/contingencyFlags.js +19 -0
- package/lib/clinical/flags/escalationFlags.js +43 -0
- package/lib/clinical/flags/flagSnapshot.js +58 -0
- package/lib/clinical/flags/inboundRecoveryFlags.js +17 -0
- package/lib/clinical/flags/llmAuditConfig.js +7 -0
- package/lib/clinical/flags/llmMonitorConfig.js +18 -0
- package/lib/clinical/flags/patternConsultFlags.js +10 -0
- package/lib/clinical/flags/recommendationRecoveryFlags.js +9 -0
- package/lib/clinical/flags/supportLightFlags.js +7 -0
- package/lib/clinical/flags/triageRecommendationFlags.js +16 -0
- package/lib/clinical/flags/turnEfficiencyFlags.js +19 -0
- package/lib/clinical/helpers/auditReasoningHelper.js +30 -0
- package/lib/clinical/helpers/carePlanInterventionDerivation.js +76 -0
- package/lib/clinical/helpers/carePlanValidationHelper.js +62 -0
- package/lib/clinical/helpers/ceilingGapHelper.js +21 -0
- package/lib/clinical/helpers/chemoContextHelper.js +217 -0
- package/lib/clinical/helpers/clinicalContextHelper.js +162 -0
- package/lib/clinical/helpers/clinicalFactsHelper.js +45 -4
- package/lib/clinical/helpers/clinicalMentionHelper.js +16 -13
- package/lib/clinical/helpers/clinicalProfileHelper.js +60 -0
- package/lib/clinical/helpers/clinicalWorkflowGuard.js +175 -0
- package/lib/clinical/helpers/cohortHelper.js +3 -1
- package/lib/clinical/helpers/contextMirrorHelper.js +68 -0
- package/lib/clinical/helpers/dateAnchorHelper.js +18 -0
- package/lib/clinical/helpers/doctorReviewMessageHelper.js +152 -0
- package/lib/clinical/helpers/drugIdentityHelper.js +67 -0
- package/lib/clinical/helpers/encodedPairHelper.js +12 -0
- package/lib/clinical/helpers/evidenceAnchorHelper.js +70 -0
- package/lib/clinical/helpers/factAssertionHelper.js +300 -0
- package/lib/clinical/helpers/gradeEstimateHelper.js +148 -0
- package/lib/clinical/helpers/hospitalizationContextHelper.js +8 -0
- package/lib/clinical/helpers/legacyContextHelper.js +122 -0
- package/lib/clinical/helpers/legacyRecommendationFormatHelper.js +107 -0
- package/lib/clinical/helpers/llmsHelper.js +170 -87
- package/lib/clinical/helpers/managedSymptomProjectionHelper.js +23 -0
- package/lib/clinical/helpers/medicationNamingRule.js +5 -0
- package/lib/clinical/helpers/palliativeAssessmentHelper.js +62 -0
- package/lib/clinical/helpers/palliativeCarePlanHelper.js +68 -0
- package/lib/clinical/helpers/recommendationGateHelper.js +208 -0
- package/lib/clinical/helpers/recommendationPlanHelper.js +104 -0
- package/lib/clinical/helpers/resultsHelper.js +56 -0
- package/lib/clinical/helpers/reviewUpdateHelper.js +68 -0
- package/lib/clinical/helpers/shadowHelper.js +1 -13
- package/lib/clinical/helpers/skillActivationHelper.js +53 -0
- package/lib/clinical/helpers/structuredTextHelper.js +13 -0
- package/lib/clinical/helpers/toolResultHelper.js +35 -0
- package/lib/clinical/helpers/triageCaseBaseHelper.js +483 -0
- package/lib/clinical/helpers/triageResultMessageHelper.js +30 -0
- package/lib/clinical/helpers/triageRetriggerHelper.js +85 -0
- package/lib/clinical/helpers/triageSymptomsHelper.js +33 -0
- package/lib/clinical/index.js +4 -0
- package/lib/clinical/memory/DefaultMemoryManager.js +211 -39
- package/lib/clinical/memory/EnhancedMemoryManager.js +14 -8
- package/lib/clinical/models/llmCallModel.js +19 -0
- package/lib/clinical/models/llmMonitorCheckpointModel.js +20 -0
- package/lib/clinical/models/llmMonitorEvaluationModel.js +56 -0
- package/lib/clinical/models/patternConsultModel.js +37 -0
- package/lib/clinical/models/riskWarmupEventModel.js +23 -0
- package/lib/clinical/models/supportCandidateModel.js +90 -0
- package/lib/clinical/models/supportLightModel.js +95 -0
- package/lib/clinical/models/triageRecommendationEventModel.js +110 -0
- package/lib/clinical/models/turnTraceModel.js +24 -7
- package/lib/clinical/monitoring/AirtableMonitorSink.js +488 -0
- package/lib/clinical/monitoring/LlmMonitorService.js +558 -0
- package/lib/clinical/monitoring/contingencyMonitorSpec.js +601 -0
- package/lib/clinical/promptPlacement.js +5 -0
- package/lib/clinical/protocols/treatmentFormulary.js +387 -0
- package/lib/clinical/providers/AnthropicProvider.js +459 -31
- package/lib/clinical/providers/BaseLLMProvider.js +689 -52
- package/lib/clinical/providers/GatewayProvider.js +14 -4
- package/lib/clinical/providers/OpenAIResponsesProvider.js +73 -11
- package/lib/clinical/providers/OpenAIResponsesProviderTools.js +24 -9
- package/lib/clinical/providers/OpenRouterProvider.js +9 -2
- package/lib/clinical/services/assistantService.js +51 -7
- package/lib/clinical/services/bridgeService.js +93 -0
- package/lib/clinical/services/checkInDueService.js +134 -0
- package/lib/clinical/services/clinicalAirtableService.js +752 -0
- package/lib/clinical/services/clinicalContextReadService.js +47 -0
- package/lib/clinical/services/clinicalExtractionService.js +156 -23
- package/lib/clinical/services/composerService.js +78 -0
- package/lib/clinical/services/conceptVerifierService.js +127 -0
- package/lib/clinical/services/conditionCloseService.js +138 -0
- package/lib/clinical/services/contextCleanupService.js +85 -0
- package/lib/clinical/services/contextMirrorService.js +72 -0
- package/lib/clinical/services/contextSyncRunner.js +20 -0
- package/lib/clinical/services/contextSyncService.js +258 -0
- package/lib/clinical/services/contingencyDispatchService.js +496 -0
- package/lib/clinical/services/ctcaeLadderService.js +70 -0
- package/lib/clinical/services/ctcaeTermService.js +44 -0
- package/lib/clinical/services/currentRegimenService.js +60 -0
- package/lib/clinical/services/deliverySettlementService.js +39 -0
- package/lib/clinical/services/deniedSymptomBoundaryService.js +218 -0
- package/lib/clinical/services/dispatcherService.js +142 -0
- package/lib/clinical/services/escalationDraftService.js +229 -0
- package/lib/clinical/services/escalationNoteFactsService.js +131 -0
- package/lib/clinical/services/escalationQuestionsService.js +131 -0
- package/lib/clinical/services/gradeAnchorService.js +85 -0
- package/lib/clinical/services/gradeClaimService.js +73 -0
- package/lib/clinical/services/gradeSourceService.js +138 -0
- package/lib/clinical/services/impressionValidationService.js +19 -0
- package/lib/clinical/services/legacyContextSyncService.js +255 -0
- package/lib/clinical/services/llmAuditService.js +23 -0
- package/lib/clinical/services/nutritionPlanService.js +97 -0
- package/lib/clinical/services/outreachCarrierService.js +88 -0
- package/lib/clinical/services/outreachSweepRunner.js +8 -0
- package/lib/clinical/services/outreachSweepService.js +644 -0
- package/lib/clinical/services/patientHistoryService.js +203 -0
- package/lib/clinical/services/patientIdentityService.js +43 -0
- package/lib/clinical/services/patientProfileService.js +145 -0
- package/lib/clinical/services/patternConsultService.js +127 -0
- package/lib/clinical/services/pausedSafetyNetService.js +387 -0
- package/lib/clinical/services/promptComposerService.js +74 -21
- package/lib/clinical/services/radiotherapyContextService.js +40 -0
- package/lib/clinical/services/radiotherapyPhaseService.js +272 -0
- package/lib/clinical/services/recommendationRankService.js +180 -0
- package/lib/clinical/services/recommendationRecoveryService.js +241 -0
- package/lib/clinical/services/recommendationValidationService.js +206 -0
- package/lib/clinical/services/regimenCloserService.js +205 -0
- package/lib/clinical/services/reminderDispatchService.js +36 -0
- package/lib/clinical/services/riskAssessmentService.js +469 -0
- package/lib/clinical/services/riskHeadlineService.js +56 -0
- package/lib/clinical/services/safetyNetPledgeService.js +231 -0
- package/lib/clinical/services/shadowMessageService.js +30 -12
- package/lib/clinical/services/shadowService.js +8 -4
- package/lib/clinical/services/skillService.js +117 -0
- package/lib/clinical/services/supportActionService.js +122 -0
- package/lib/clinical/services/supportCandidateService.js +607 -0
- package/lib/clinical/services/supportInvitability.js +86 -0
- package/lib/clinical/services/supportLightEvaluationService.js +231 -0
- package/lib/clinical/services/supportLightService.js +277 -0
- package/lib/clinical/services/supportRoutingAgentService.js +118 -0
- package/lib/clinical/services/symptomLandscapeService.js +153 -0
- package/lib/clinical/services/treatmentProposalService.js +136 -0
- package/lib/clinical/services/triageRecommendationService.js +1226 -0
- package/lib/clinical/services/turnRiskBriefService.js +217 -0
- package/lib/clinical/services/writeClaimStore.js +126 -0
- package/lib/clinical/stores/CtcaeCatalog.js +21 -0
- package/lib/clinical/tools/analyzeSymptomPatternsTool.js +276 -0
- package/lib/clinical/tools/deliverPatientMessageTool.js +294 -0
- package/lib/clinical/tools/extractClinicalInfoTool.js +252 -37
- package/lib/clinical/tools/getActiveRecommendationsTool.js +44 -0
- package/lib/clinical/tools/getActiveSymptomLandscapeTool.js +37 -0
- package/lib/clinical/tools/getPatientHistoryTool.js +45 -0
- package/lib/clinical/tools/getPatientRiskAssessmentTool.js +66 -0
- package/lib/clinical/tools/getRouterContextBundleTool.js +136 -0
- package/lib/clinical/tools/lookupCtcaeEntryTool.js +36 -0
- package/lib/clinical/tools/openClusterHypothesisTool.js +175 -0
- package/lib/clinical/tools/openConditionTool.js +198 -0
- package/lib/clinical/tools/recordClinicalImpressionTool.js +394 -0
- package/lib/clinical/tools/recordInterventionTool.js +138 -0
- package/lib/clinical/tools/recordRecommendationOutcomeTool.js +72 -0
- package/lib/clinical/tools/registerClinicalTools.js +51 -6
- package/lib/clinical/tools/reportCrisisTool.js +193 -0
- package/lib/clinical/tools/reportMedicalEscalationTool.js +471 -0
- package/lib/clinical/tools/reportResultsReceivedTool.js +176 -0
- package/lib/clinical/tools/reportUnresolvedRequestv2Tool.js +164 -0
- package/lib/clinical/tools/requestPatternConsultTool.js +70 -0
- package/lib/clinical/tools/schedulePatientReminderTool.js +292 -0
- package/lib/clinical/tools/sendBridgeMessageTool.js +33 -0
- package/lib/clinical/tools/setContingencyPlanTool.js +332 -0
- package/lib/clinical/tools/skillTool.js +81 -0
- package/lib/clinical/tools/submitNutritionSafetyDecisionTool.js +200 -0
- package/lib/clinical/tools/submitOutreachDecisionTool.js +139 -0
- package/lib/clinical/tools/submitPalliativeAssessmentTool.js +75 -0
- package/lib/clinical/tools/submitPalliativeCarePlanTool.js +101 -0
- package/lib/clinical/tools/submitRecommendationPlanTool.js +145 -0
- package/lib/clinical/tools/submitRoutingDecisionTool.js +466 -0
- package/lib/clinical/tools/submitSafetyGateTool.js +130 -0
- package/lib/clinical/tools/submitSupportRoutingRecommendationTool.js +149 -0
- package/lib/clinical/tools/updateClusterHypothesisTool.js +178 -0
- package/lib/clinical/tools/updateConditionStatusTool.js +192 -0
- package/lib/clinical/tools/updatePalliativeAssessmentTool.js +78 -0
- package/lib/config/airtableArchiveConfig.js +177 -0
- package/lib/config/airtableConfig.js +24 -1
- package/lib/config/instructionConfig.js +5 -0
- package/lib/config/lifecycle.js +36 -1
- package/lib/config/programConfig.js +20 -0
- package/lib/controllers/assistantController.js +67 -11
- package/lib/controllers/contextSyncController.js +30 -0
- package/lib/controllers/contingencyController.js +28 -0
- package/lib/controllers/conversationController.js +7 -7
- package/lib/controllers/dashboardController.js +7 -4
- package/lib/controllers/escalationReviewController.js +299 -0
- package/lib/controllers/healthController.js +16 -0
- package/lib/controllers/interactionController.js +1 -1
- package/lib/controllers/messageController.js +67 -19
- package/lib/controllers/officeAssistantController.js +57 -0
- package/lib/controllers/patientController.js +216 -48
- package/lib/controllers/prescriptionController.js +10 -3
- package/lib/controllers/templateController.js +8 -17
- package/lib/controllers/traceController.js +26 -0
- package/lib/controllers/triageRecommendationController.js +41 -0
- package/lib/controllers/uploadController.js +2 -2
- package/lib/core/BatchingManager.js +146 -11
- package/lib/core/DeferredWorkRunner.js +257 -0
- package/lib/core/MessageParser.js +2 -2
- package/lib/core/NexusMessaging.js +948 -146
- package/lib/core/PhiProcessor.js +198 -17
- package/lib/core/ProcessingPipeline.js +49 -4
- package/lib/core/interactiveRouteService.js +64 -0
- package/lib/core/runtimeToolPolicy.js +3 -0
- package/lib/eval/EvalProvider.js +72 -25
- package/lib/fhir/config/catalogConfig.js +9 -14
- package/lib/fhir/config/fhirConfig.js +16 -12
- package/lib/fhir/constants/escalationCaseStatus.js +31 -0
- package/lib/fhir/constants/extensionSlugs.js +195 -0
- package/lib/fhir/constants/gradeMethods.js +12 -0
- package/lib/fhir/constants/projectionSlugs.js +69 -1
- package/lib/fhir/constants/severityPriority.js +8 -0
- package/lib/fhir/constants/variableRegistry.js +60 -0
- package/lib/fhir/helpers/compositeHelper.js +65 -12
- package/lib/fhir/helpers/contextArbitrationHelper.js +41 -0
- package/lib/fhir/helpers/elementHelper.js +39 -0
- package/lib/fhir/helpers/fhirHelper.js +4 -1
- package/lib/fhir/helpers/fhirReadHelper.js +62 -0
- package/lib/fhir/helpers/recommendationIds.js +44 -0
- package/lib/fhir/helpers/resourceDisplayHelper.js +9 -0
- package/lib/fhir/helpers/resourceHelper.js +46 -0
- package/lib/fhir/helpers/symptomAliasHelper.js +56 -0
- package/lib/fhir/helpers/termMatchHelper.js +42 -0
- package/lib/fhir/helpers/terminologyHelper.js +92 -5
- package/lib/fhir/helpers/triagePayloadHelper.js +133 -0
- package/lib/fhir/helpers/variableRegistryHelper.js +21 -0
- package/lib/fhir/index.js +75 -0
- package/lib/fhir/models/envelopeModel.js +22 -0
- package/lib/fhir/projections/clinicalMentionProjection.js +208 -46
- package/lib/fhir/projections/clusterProjection.js +124 -0
- package/lib/fhir/projections/contextFactProjection.js +380 -0
- package/lib/fhir/projections/contingencyProjection.js +224 -0
- package/lib/fhir/projections/dispatchedEscalationProjection.js +63 -0
- package/lib/fhir/projections/interventionProjection.js +245 -0
- package/lib/fhir/projections/palliativeCarePlanProjection.js +183 -0
- package/lib/fhir/projections/palliativeProjection.js +175 -0
- package/lib/fhir/projections/proctcaeProjection.js +62 -15
- package/lib/fhir/projections/recommendationPlanProjection.js +557 -0
- package/lib/fhir/projections/registerProjectors.js +10 -2
- package/lib/fhir/projections/reminderProjection.js +20 -0
- package/lib/fhir/projections/riskProjection.js +16 -0
- package/lib/fhir/projections/routingProjection.js +285 -0
- package/lib/fhir/projections/safetyGateProjection.js +42 -0
- package/lib/fhir/projections/symptomCaseProjection.js +324 -0
- package/lib/fhir/resources/CommunicationRequest.js +91 -0
- package/lib/fhir/resources/Condition.js +2 -24
- package/lib/fhir/resources/Encounter.js +30 -0
- package/lib/fhir/resources/Observation.js +22 -69
- package/lib/fhir/resources/Patient.js +57 -6
- package/lib/fhir/resources/Provenance.js +48 -12
- package/lib/fhir/resources/RiskAssessment.js +184 -0
- package/lib/fhir/resources/Task.js +102 -0
- package/lib/fhir/services/clinicalContextService.js +161 -0
- package/lib/fhir/services/clinicalMentionService.js +3 -5
- package/lib/fhir/services/clusterService.js +30 -0
- package/lib/fhir/services/contingencyService.js +47 -0
- package/lib/fhir/services/encounterService.js +16 -0
- package/lib/fhir/services/escalationService.js +85 -0
- package/lib/fhir/services/fhirService.js +20 -0
- package/lib/fhir/services/interventionService.js +50 -0
- package/lib/fhir/services/palliativeService.js +74 -0
- package/lib/fhir/services/patientService.js +41 -0
- package/lib/fhir/services/recommendationService.js +336 -0
- package/lib/fhir/services/resultObservationService.js +53 -0
- package/lib/fhir/services/riskService.js +202 -0
- package/lib/fhir/services/routingService.js +86 -0
- package/lib/fhir/services/snapshotService.js +18 -3
- package/lib/fhir/services/symptomCaseService.js +33 -0
- package/lib/fhir/services/terminologyService.js +16 -21
- package/lib/fhir/services/triageService.js +8 -4
- package/lib/fhir/stores/fhirStore.js +42 -19
- package/lib/fhir/utils/normalizeUtils.js +12 -0
- package/lib/helpers/airtableArchiveHelper.js +51 -0
- package/lib/helpers/airtableFormulaHelper.js +25 -0
- package/lib/helpers/caregiverHelper.js +136 -0
- package/lib/helpers/channelErrorHelper.js +31 -0
- package/lib/helpers/channelRetryHelper.js +156 -0
- package/lib/helpers/conversationWindowHelper.js +2 -2
- package/lib/helpers/deliveryAttemptHelper.js +14 -2
- package/lib/helpers/filesHelper.js +3 -3
- package/lib/helpers/healthHelper.js +40 -0
- package/lib/helpers/messageHelper.js +16 -6
- package/lib/helpers/messageStatusHelper.js +16 -22
- package/lib/helpers/metaSignatureHelper.js +6 -6
- package/lib/helpers/nerHelper.js +24 -0
- package/lib/helpers/outboundAllowlistHelper.js +51 -0
- package/lib/helpers/patientInformationHelper.js +20 -16
- package/lib/helpers/patientMessageHelper.js +79 -0
- package/lib/helpers/patientTaskRulesHelper.js +57 -0
- package/lib/helpers/pausedThreadHelper.js +37 -0
- package/lib/helpers/processHelper.js +47 -16
- package/lib/helpers/sendClaimHelper.js +126 -0
- package/lib/helpers/staffSendHelper.js +4 -0
- package/lib/helpers/templateFlowControllerHelper.js +1 -1
- package/lib/helpers/templateRecoveryHelper.js +66 -8
- package/lib/helpers/triageRecordHelper.js +124 -0
- package/lib/helpers/twilioHelper.js +7 -79
- package/lib/helpers/twilioMediaHelper.js +1 -1
- package/lib/helpers/whatsappHelper.js +3 -1
- package/lib/index.d.ts +844 -34
- package/lib/index.js +169 -11
- package/lib/jobs/ScheduledMessageJob.js +44 -0
- package/lib/jobs/TemplateApprovalJob.js +200 -33
- package/lib/models/agendaMessageModel.js +5 -0
- package/lib/models/airtableArchiveModel.js +225 -0
- package/lib/models/contactGateDecisionModel.js +27 -0
- package/lib/models/contextSyncStateModel.js +26 -0
- package/lib/models/deferredWorkModel.js +24 -0
- package/lib/models/deliveryAttemptModel.js +5 -1
- package/lib/models/escalationReviewModel.js +341 -0
- package/lib/models/flowRoutingModel.js +1 -1
- package/lib/models/messageModel.js +21 -1
- package/lib/models/patientProfileModel.js +24 -0
- package/lib/models/safetyNetPledgeModel.js +31 -0
- package/lib/models/sendClaimModel.js +18 -0
- package/lib/models/templateModel.js +1 -2
- package/lib/models/threadModel.js +7 -0
- package/lib/models/tokenMapModel.js +2 -1
- package/lib/models/writeClaimModel.js +14 -0
- package/lib/observability/telemetry.js +7 -7
- package/lib/providers/NerClient.js +2 -2
- package/lib/queue/QueueAdapter.js +1 -0
- package/lib/queue/RedisQueueAdapter.js +104 -7
- package/lib/routes/index.js +132 -2
- package/lib/services/airtableArchivePlanService.js +197 -0
- package/lib/services/airtableArchiveReadService.js +48 -0
- package/lib/services/airtableArchiveService.js +561 -0
- package/lib/services/airtableMirrorService.js +223 -0
- package/lib/services/airtableService.js +198 -18
- package/lib/services/assistantMessageService.js +140 -0
- package/lib/services/carePlanHistoryService.js +610 -0
- package/lib/services/characterizationOutcomeService.js +294 -0
- package/lib/services/contactGateService.js +178 -0
- package/lib/services/conversationService.js +66 -20
- package/lib/services/dashboard-provider-registry.js +38 -0
- package/lib/services/dashboardService.js +31 -4
- package/lib/services/escalationCaseTaskService.js +134 -0
- package/lib/services/escalationContextService.js +92 -0
- package/lib/services/escalationReviewService.js +2214 -0
- package/lib/services/flowDataExchangeService.js +1 -1
- package/lib/services/globalEntityService.js +1 -1
- package/lib/services/gravePendingService.js +41 -0
- package/lib/services/healthService.js +252 -0
- package/lib/services/heldMessageService.js +141 -0
- package/lib/services/inboundRecoveryService.js +354 -0
- package/lib/services/instructionInFlightService.js +17 -0
- package/lib/services/officeAssistantService.js +217 -0
- package/lib/services/orbisService.js +44 -0
- package/lib/services/patientClinicalStatusService.js +189 -0
- package/lib/services/patientResourceService.js +24 -0
- package/lib/services/patientService.js +28 -16
- package/lib/services/patientTaskService.js +221 -0
- package/lib/services/patientTaskSummaryService.js +93 -0
- package/lib/services/physicianService.js +31 -0
- package/lib/services/preprocessingService.js +18 -6
- package/lib/services/queueReconciliationService.js +161 -0
- package/lib/services/recommendationCarouselService.js +398 -0
- package/lib/services/reviewAlertSweepService.js +99 -0
- package/lib/services/reviewBoardService.js +75 -0
- package/lib/services/reviewDeadlineService.js +116 -0
- package/lib/services/reviewDraftSweepService.js +85 -0
- package/lib/services/teamAlertService.js +140 -0
- package/lib/services/templateService.js +1 -2
- package/lib/{helpers/threadHelper.js → services/threadService.js} +38 -6
- package/lib/services/tokenMapService.js +119 -22
- package/lib/services/toolRegistryService.js +43 -2
- package/lib/services/triageHistoryService.js +128 -0
- package/lib/services/twilioMediaService.js +79 -0
- package/lib/services/undeliverableService.js +36 -0
- package/lib/services/untakenAlertService.js +210 -0
- package/lib/shared/dtos/ClinicalAssertion.js +21 -0
- package/lib/shared/dtos/ClinicalMention.js +4 -0
- package/lib/shared/dtos/ClusterImpression.js +16 -5
- package/lib/shared/dtos/ContingencySafetyNet.js +69 -7
- package/lib/shared/dtos/DispatchedEscalation.js +4 -8
- package/lib/shared/dtos/GradedSymptom.js +2 -0
- package/lib/shared/dtos/Intervention.js +10 -3
- package/lib/shared/dtos/ManagedSymptom.js +40 -11
- package/lib/shared/dtos/NutritionSafetyDecision.js +128 -0
- package/lib/shared/dtos/PalliativeAssessment.js +62 -0
- package/lib/shared/dtos/PalliativeCarePlan.js +47 -0
- package/lib/shared/dtos/PatientRiskAssessment.js +25 -1
- package/lib/shared/dtos/RecommendationPlan.js +102 -0
- package/lib/shared/dtos/RecommendationSafetyGate.js +64 -0
- package/lib/shared/dtos/Reminder.js +2 -2
- package/lib/shared/dtos/RoutingDecision.js +2 -1
- package/lib/shared/dtos/SupportAction.js +28 -0
- package/lib/shared/dtos/SupportRoutingRecommendation.js +124 -0
- package/lib/shared/dtos/TriageCompletion.js +50 -0
- package/lib/shared/dtos/TriageResponse.js +7 -1
- package/lib/storage/MongoStorage.js +10 -1
- package/lib/templates/predefinedTemplates.js +1 -1
- package/lib/templates/templateStructure.js +15 -2
- package/lib/utils/MapCache.js +1 -1
- package/lib/utils/coercionUtils.js +11 -0
- package/lib/utils/concurrencyUtils.js +13 -0
- package/lib/utils/dateUtils.js +114 -6
- package/lib/utils/errorUtils.js +26 -1
- package/lib/utils/formatUtils.js +43 -37
- package/lib/utils/httpErrorUtils.js +9 -0
- package/lib/utils/intervalSweeper.js +75 -0
- package/lib/utils/jsonUtils.js +51 -0
- package/lib/utils/logger.js +8 -6
- package/lib/utils/paginationUtils.js +30 -0
- package/lib/utils/retryUtils.js +9 -1
- package/lib/utils/sanitizerUtils.js +87 -1
- package/lib/utils/scheduleUtils.js +70 -1
- package/lib/utils/shadowScope.js +13 -0
- package/lib/utils/statsUtils.js +21 -0
- package/lib/utils/textMatchUtils.js +76 -0
- package/lib/utils/timeoutUtils.js +16 -0
- package/lib/utils/tokenMapUtils.js +3 -3
- package/package.json +11 -11
- package/lib/clinical/helpers/divergenceHelper.js +0 -100
- package/lib/clinical/models/divergenceModel.js +0 -41
- package/lib/clinical/services/clinicalAgentService.js +0 -18
- package/lib/clinical/services/divergenceService.js +0 -90
- package/lib/core/workflowRunner.js +0 -35
- package/lib/fhir/resources/Appointment.js +0 -28
- package/lib/fhir/resources/MedicationStatement.js +0 -42
- package/lib/fhir/resources/Procedure.js +0 -30
- package/lib/services/twilioService.js +0 -13
|
@@ -2,19 +2,13 @@ const { Config_ID } = require('../../config/airtableConfig');
|
|
|
2
2
|
|
|
3
3
|
const { getRecordByFilter } = require('../../services/airtableService');
|
|
4
4
|
|
|
5
|
-
const MapCache = require('../../utils/MapCache');
|
|
6
5
|
const { safeParse } = require('../../utils/jsonUtils');
|
|
7
6
|
|
|
8
7
|
const CATALOG_TABLE = 'fhir_resources';
|
|
9
|
-
const CACHE_TTL = 5 * 60 * 1000;
|
|
10
|
-
const CACHE_KEY = 'fhirCatalog';
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
async function load() {
|
|
15
|
-
const cached = cache.get(CACHE_KEY);
|
|
16
|
-
if (cached) return cached;
|
|
9
|
+
let state = null;
|
|
17
10
|
|
|
11
|
+
async function initialize() {
|
|
18
12
|
const records = await getRecordByFilter(Config_ID, CATALOG_TABLE, 'TRUE()');
|
|
19
13
|
if (!records || !records.length) {
|
|
20
14
|
throw new Error(`fhir catalog missing from Config base: table ${CATALOG_TABLE} is empty or unreachable`);
|
|
@@ -36,11 +30,12 @@ async function load() {
|
|
|
36
30
|
throw new Error(`fhir catalog is empty: no rows in ${CATALOG_TABLE} carry a resource type`);
|
|
37
31
|
}
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
state = { catalog, resourceTypes };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getCatalog() {
|
|
37
|
+
if (!state) throw new Error('fhir catalog not loaded: call initialize() at startup');
|
|
38
|
+
return state;
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
module.exports = {
|
|
45
|
-
getCatalog: () => load(),
|
|
46
|
-
};
|
|
41
|
+
module.exports = { initialize, getCatalog };
|
|
@@ -3,12 +3,17 @@ const { Config_ID } = require('../../config/airtableConfig');
|
|
|
3
3
|
const { getRecordByFilter } = require('../../services/airtableService');
|
|
4
4
|
|
|
5
5
|
const { safeParse, safeParseArray } = require('../../utils/jsonUtils');
|
|
6
|
+
const { logger } = require('../../utils/logger');
|
|
6
7
|
|
|
7
8
|
const FHIR_CONFIG_TABLE = 'fhir';
|
|
9
|
+
// Every stored resource key, extension url and code system is built on these. They are identity, not
|
|
10
|
+
// configuration: an edited base would fork the corpus into duplicates and orphan every stored extension.
|
|
11
|
+
const BASES = {
|
|
12
|
+
IDENT_BASE: 'https://peopl.health/fhir/identifier',
|
|
13
|
+
EXT_BASE: 'https://peopl.health/fhir/StructureDefinition',
|
|
14
|
+
CODESYSTEM_BASE: 'https://peopl.health/fhir/CodeSystem',
|
|
15
|
+
};
|
|
8
16
|
const REQUIRED_KEYS = [
|
|
9
|
-
'IDENT_BASE',
|
|
10
|
-
'EXT_BASE',
|
|
11
|
-
'CODESYSTEM_BASE',
|
|
12
17
|
'SYSTEMS',
|
|
13
18
|
'SUSPECTED_GRADE_DISPLAYS',
|
|
14
19
|
'QUESTIONNAIRE_CANONICAL_URL',
|
|
@@ -18,9 +23,6 @@ const REQUIRED_KEYS = [
|
|
|
18
23
|
];
|
|
19
24
|
|
|
20
25
|
const state = {
|
|
21
|
-
identBase: null,
|
|
22
|
-
extBase: null,
|
|
23
|
-
codesystemBase: null,
|
|
24
26
|
systems: null,
|
|
25
27
|
suspectedGradeDisplays: null,
|
|
26
28
|
questionnaireCanonicalUrl: null,
|
|
@@ -43,9 +45,11 @@ async function initialize() {
|
|
|
43
45
|
const suspectedGradeDisplays = safeParseArray(byKey.SUSPECTED_GRADE_DISPLAYS, null);
|
|
44
46
|
if (!suspectedGradeDisplays) throw new Error('fhir config SUSPECTED_GRADE_DISPLAYS is not a JSON array');
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
for (const [key, value] of Object.entries(BASES)) {
|
|
49
|
+
if (byKey[key] && byKey[key] !== value) {
|
|
50
|
+
logger.error('[fhirConfig] Config base value ignored: FHIR identity bases are fixed in code', { key, configured: byKey[key], used: value });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
49
53
|
state.systems = systems;
|
|
50
54
|
state.suspectedGradeDisplays = suspectedGradeDisplays;
|
|
51
55
|
state.questionnaireCanonicalUrl = byKey.QUESTIONNAIRE_CANONICAL_URL;
|
|
@@ -60,9 +64,9 @@ function assertLoaded() {
|
|
|
60
64
|
|
|
61
65
|
module.exports = {
|
|
62
66
|
initialize,
|
|
63
|
-
getIdentBase: () =>
|
|
64
|
-
getExtBase: () =>
|
|
65
|
-
getCodesystemBase: () =>
|
|
67
|
+
getIdentBase: () => BASES.IDENT_BASE,
|
|
68
|
+
getExtBase: () => BASES.EXT_BASE,
|
|
69
|
+
getCodesystemBase: () => BASES.CODESYSTEM_BASE,
|
|
66
70
|
getSystems: () => { assertLoaded(); return state.systems; },
|
|
67
71
|
getSuspectedGradeDisplays: () => { assertLoaded(); return state.suspectedGradeDisplays; },
|
|
68
72
|
getQuestionnaireCanonicalUrl: () => { assertLoaded(); return state.questionnaireCanonicalUrl; },
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const CASE = (status, businessStatus, label) => ({ status, businessStatus, label });
|
|
2
|
+
|
|
3
|
+
const POR_REVISAR = CASE('requested', 'por-revisar', 'Por revisar');
|
|
4
|
+
const EN_EVALUACION = CASE('in-progress', 'en-evaluacion', 'En evaluación');
|
|
5
|
+
const CON_MEDICO = CASE('in-progress', 'con-medico', 'Con el médico');
|
|
6
|
+
const POR_ENVIAR = CASE('in-progress', 'indicacion-por-enviar', 'Indicación por enviar');
|
|
7
|
+
|
|
8
|
+
const CASE_STATUS_BY_REVIEW_STATUS = Object.freeze({
|
|
9
|
+
open: POR_REVISAR,
|
|
10
|
+
documenting: EN_EVALUACION,
|
|
11
|
+
draft_ready: EN_EVALUACION,
|
|
12
|
+
returned: EN_EVALUACION,
|
|
13
|
+
handing_off: CON_MEDICO,
|
|
14
|
+
awaiting_doctor: CON_MEDICO,
|
|
15
|
+
approved: POR_ENVIAR,
|
|
16
|
+
sending: POR_ENVIAR,
|
|
17
|
+
needs_intervention: CASE('in-progress', 'requiere-valoracion', 'Requiere valoración'),
|
|
18
|
+
indications_queued: CASE('on-hold', 'esperando-paciente', 'Esperando paciente'),
|
|
19
|
+
indications_sent: CASE('in-progress', 'indicaciones-dadas', 'Indicaciones dadas'),
|
|
20
|
+
monitoring: CASE('in-progress', 'en-vigilancia', 'En vigilancia'),
|
|
21
|
+
closed: CASE('completed', 'cerrado', 'Cerrado'),
|
|
22
|
+
cancelled: CASE('cancelled', 'no-requiere', 'No requiere'),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function caseStatusOf(reviewStatus) {
|
|
26
|
+
const caseStatus = CASE_STATUS_BY_REVIEW_STATUS[reviewStatus];
|
|
27
|
+
if (!caseStatus) throw new Error(`no case status for review status ${reviewStatus}`);
|
|
28
|
+
return caseStatus;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { CASE_STATUS_BY_REVIEW_STATUS, caseStatusOf };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
const PATIENT_EXT = {
|
|
2
|
+
AGE: 'patient-age',
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const CONTEXT_EXT = {
|
|
6
|
+
VARIABLE_ID: 'context-variable-id',
|
|
7
|
+
SOURCE: 'context-source',
|
|
8
|
+
TRUST: 'context-trust',
|
|
9
|
+
VALID_TIME: 'context-valid-time',
|
|
10
|
+
RECORD_TIME: 'context-record-time',
|
|
11
|
+
ALTERNATE: 'context-alternate',
|
|
12
|
+
ALTERNATE_VALUE: 'context-alternate-value',
|
|
13
|
+
OPEN_CONFLICT: 'context-open-conflict',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const SYMPTOM_CASE_EXT = {
|
|
17
|
+
STATUS: 'symptom-case-status',
|
|
18
|
+
LEGACY_ABATEMENT: 'legacy-abatement',
|
|
19
|
+
CLOSE_REASON: 'symptom-close-reason',
|
|
20
|
+
TEMPORALITY: 'symptom-temporality',
|
|
21
|
+
CURRENT_EPISODE_ID: 'symptom-current-episode-id',
|
|
22
|
+
EVIDENCE_EPISODE_IDS: 'symptom-evidence-episode-ids',
|
|
23
|
+
EVIDENCE_MENTION_IDS: 'symptom-evidence-mention-ids',
|
|
24
|
+
RECURRENCE_COUNT: 'symptom-recurrence-count',
|
|
25
|
+
REACTIVATED_AT: 'symptom-reactivated-at',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ASSESSMENT_EXT = {
|
|
29
|
+
TRAJECTORY: 'trajectory',
|
|
30
|
+
DECISION_POSTURE: 'decision-posture',
|
|
31
|
+
POSTURE_REASON: 'posture-reason',
|
|
32
|
+
REASONING: 'assessment-reasoning',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const GRADE_EXT = {
|
|
36
|
+
CONFIDENCE: 'grade-confidence',
|
|
37
|
+
RANGE: 'grade-range',
|
|
38
|
+
REASONING: 'grade-reasoning',
|
|
39
|
+
VERIFICATION: 'grade-verification',
|
|
40
|
+
THRESHOLD_CLAUSE: 'grade-threshold-clause',
|
|
41
|
+
FUNCTIONAL_ANCHOR: 'grade-functional-anchor',
|
|
42
|
+
MATCHED_GRADE: 'grade-matched-clause',
|
|
43
|
+
IMPROVEMENT_BASIS: 'grade-improvement-basis',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const MENTION_EXT = {
|
|
47
|
+
ASSERTION_NEGATED: 'mention-assertion-negated',
|
|
48
|
+
ASSERTION_HEDGED: 'mention-assertion-hedged',
|
|
49
|
+
ASSERTION_EXPERIENCER: 'mention-assertion-experiencer',
|
|
50
|
+
ASSERTION_TEMPORAL: 'mention-assertion-temporal',
|
|
51
|
+
ASSERTION_CONFIDENCE: 'mention-assertion-confidence',
|
|
52
|
+
TEMPORALITY: 'mention-temporality',
|
|
53
|
+
TURN_ID: 'mention-turn-id',
|
|
54
|
+
SOURCE: 'mention-source',
|
|
55
|
+
EXTRACTOR_CONFIDENCE: 'mention-extractor-confidence',
|
|
56
|
+
NEEDS_CONFIRMATION: 'mention-needs-confirmation',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const RECOMMENDATION_EXT = {
|
|
60
|
+
OUTCOME_SOURCE: 'recommendation-outcome-source',
|
|
61
|
+
OUTCOME_ADHERENCE: 'recommendation-outcome-adherence',
|
|
62
|
+
OUTCOME_NOTES: 'recommendation-outcome-notes',
|
|
63
|
+
OUTCOME_RECORDED_AT: 'recommendation-outcome-recorded-at',
|
|
64
|
+
OUTCOME_EVENT: 'recommendation-outcome-event',
|
|
65
|
+
ORIGIN: 'recommendation-origin',
|
|
66
|
+
TURN_ID: 'recommendation-turn-id',
|
|
67
|
+
SAFETY_CONFIRMATION_NEEDED: 'recommendation-safety-confirmation-needed',
|
|
68
|
+
SAFETY_CONFIRMATION_QUESTION: 'recommendation-safety-confirmation-question',
|
|
69
|
+
VITAL_RISK_POSSIBLE_NOW: 'recommendation-vital-risk-possible-now',
|
|
70
|
+
ELEMENT_RANK: 'recommendation-element-rank',
|
|
71
|
+
ELEMENT_TYPE: 'recommendation-element-type',
|
|
72
|
+
ELEMENT_TIME_WINDOW: 'recommendation-element-time-window',
|
|
73
|
+
ELEMENT_WHY_RELEVANT: 'recommendation-element-why-relevant',
|
|
74
|
+
ELEMENT_GROUNDED_IN: 'recommendation-element-grounded-in',
|
|
75
|
+
ELEMENT_EVIDENCE: 'recommendation-element-evidence',
|
|
76
|
+
QUALITY_WARNING: 'recommendation-quality-warning',
|
|
77
|
+
ELEMENT_QOL_IMPACT: 'recommendation-element-qol-impact',
|
|
78
|
+
ELEMENT_IMPROVEMENT_CAPACITY: 'recommendation-element-improvement-capacity',
|
|
79
|
+
ELEMENT_SYMPTOM: 'recommendation-element-symptom',
|
|
80
|
+
ELEMENT_SYMPTOM_PATIENT_FACING: 'recommendation-element-symptom-patient-facing',
|
|
81
|
+
ELEMENT_ESCALATION_URGENT: 'recommendation-element-escalation-urgent-under-24h',
|
|
82
|
+
ELEMENT_ESCALATION_MAX_HOURS: 'recommendation-element-escalation-max-action-hours',
|
|
83
|
+
ELEMENT_ESCALATION_ROUTE: 'recommendation-element-escalation-route',
|
|
84
|
+
ELEMENT_ESCALATION_CRITERIA: 'recommendation-element-escalation-clinical-criteria',
|
|
85
|
+
REC_RUN_ID: 'recommendation-rec-run-id',
|
|
86
|
+
REC_OTC_OFFER: 'recommendation-otc-offer',
|
|
87
|
+
REC_FOLLOWUP: 'recommendation-followup',
|
|
88
|
+
REC_FOLLOWUP_URGENCY: 'recommendation-followup-urgency',
|
|
89
|
+
PRODUCED_BY_MODEL: 'recommendation-produced-by-model',
|
|
90
|
+
METHOD_VERSION: 'recommendation-method-version',
|
|
91
|
+
REVIEW_VERDICT: 'recommendation-review-verdict',
|
|
92
|
+
REVIEW_NOTE: 'recommendation-review-note',
|
|
93
|
+
REVIEW_CORRECTED_TEXT: 'recommendation-review-corrected-text',
|
|
94
|
+
REVIEW_BY: 'recommendation-review-by',
|
|
95
|
+
REVIEW_RECORDED_AT: 'recommendation-review-recorded-at',
|
|
96
|
+
REVIEW_EVENT: 'recommendation-review-event',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const SAFETY_GATE_EXT = {
|
|
100
|
+
URGENT_UNDER_24H: 'safety-gate-urgent-under-24h',
|
|
101
|
+
MAX_ACTION_TIME_HOURS: 'safety-gate-max-action-time-hours',
|
|
102
|
+
ESCALATION_ROUTE: 'safety-gate-escalation-route',
|
|
103
|
+
REASON_FOR_ESCALATION: 'safety-gate-reason-for-escalation',
|
|
104
|
+
RED_FLAG: 'safety-gate-red-flag',
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const ROUTING_EXT = {
|
|
108
|
+
TURN_ID: 'routing-turn-id',
|
|
109
|
+
DECISION_ID: 'routing-decision-id',
|
|
110
|
+
COMMITTED_AT: 'routing-committed-at',
|
|
111
|
+
PRIMARY_CASE_ID: 'routing-primary-case-id',
|
|
112
|
+
DEFERRED_ITEM: 'routing-deferred-item',
|
|
113
|
+
DEFERRED_REASON: 'routing-deferred-reason',
|
|
114
|
+
FINDING_CASE_ID: 'routing-finding-case-id',
|
|
115
|
+
FINDING_REASONING: 'routing-finding-reasoning',
|
|
116
|
+
FINDING_ACTION: 'routing-finding-action',
|
|
117
|
+
PREVIOUS_ID: 'routing-previous-id',
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const CLUSTER_EXT = {
|
|
121
|
+
HYPOTHESIS_TYPE: 'clusterHypothesisType',
|
|
122
|
+
CONFIDENCE: 'clusterHypothesisConfidence',
|
|
123
|
+
CLINICAL_SIGNIFICANCE: 'clusterClinicalSignificance',
|
|
124
|
+
STRENGTHENS_IF: 'clusterStrengthensIf',
|
|
125
|
+
WEAKENS_IF: 'clusterWeakensIf',
|
|
126
|
+
STATUS: 'cluster-status',
|
|
127
|
+
CONSULTATION_ID: 'cluster-consultation-id',
|
|
128
|
+
DISSOLVE_REASON: 'cluster-dissolve-reason',
|
|
129
|
+
MEMBER_CASE_ID: 'cluster-member-case-id',
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const PALLIATIVE_EXT = {
|
|
133
|
+
TURN_ID: 'palliative-turn-id',
|
|
134
|
+
ASSESSMENT_ID: 'palliative-assessment-id',
|
|
135
|
+
ESCALATION_RANK: 'palliative-escalation-rank',
|
|
136
|
+
CAREPLAN_REC_RANK: 'palliative-careplan-rec-rank',
|
|
137
|
+
CAREPLAN_OTC_OFFER: 'palliative-careplan-otc-offer',
|
|
138
|
+
FINDING_RANK: 'palliative-finding-rank',
|
|
139
|
+
FINDING_ELEMENT_TYPE: 'palliative-finding-element-type',
|
|
140
|
+
FINDING_TIME_WINDOW: 'palliative-finding-time-window',
|
|
141
|
+
FINDING_SYMPTOM_TERM: 'palliative-finding-symptom-term',
|
|
142
|
+
FINDING_CLINICAL_DESCRIPTION: 'palliative-finding-clinical-description',
|
|
143
|
+
FINDING_WHY_RELEVANT: 'palliative-finding-why-relevant',
|
|
144
|
+
FINDING_QOL_IMPACT: 'palliative-finding-qol-impact',
|
|
145
|
+
FINDING_QOL_CRITERIA: 'palliative-finding-qol-criteria',
|
|
146
|
+
FINDING_IMPROVEMENT_CAPACITY: 'palliative-finding-improvement-capacity',
|
|
147
|
+
FINDING_IMPROVEMENT_CRITERIA: 'palliative-finding-improvement-criteria',
|
|
148
|
+
FINDING_ARE_MEDS_NEEDED: 'palliative-finding-are-meds-needed',
|
|
149
|
+
FINDING_NEEDS_CHARACTERIZATION: 'palliative-finding-needs-characterization',
|
|
150
|
+
FINDING_CHARACTERIZATION_CRITERIA: 'palliative-finding-characterization-criteria',
|
|
151
|
+
FINDING_PROBE_QUESTION: 'palliative-finding-probe-question',
|
|
152
|
+
FINDING_AUDIT_NOTES: 'palliative-finding-audit-notes',
|
|
153
|
+
FINDING_CLUSTER_NOTE: 'palliative-finding-cluster-note',
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const RISK_EXT = {
|
|
157
|
+
PREDICTION_KIND: 'risk-prediction-kind',
|
|
158
|
+
RELATED_SYMPTOM_TERM: 'risk-related-symptom-term',
|
|
159
|
+
MINIMUM_SYMPTOM_SET: 'risk-minimum-symptom-set',
|
|
160
|
+
DISEASE_COMPLICATION: 'risk-disease-complication',
|
|
161
|
+
DISEASE_WARNING_SYMPTOM: 'risk-disease-warning-symptom',
|
|
162
|
+
DISEASE_AMPLIFIER: 'risk-disease-amplifier',
|
|
163
|
+
COMORBIDITY_CLINICAL_NOTE: 'risk-comorbidity-clinical-note',
|
|
164
|
+
SOURCE_REGIMEN: 'assessed-source-regimen',
|
|
165
|
+
SOURCE_DIAGNOSIS: 'assessed-source-diagnosis',
|
|
166
|
+
SOURCE_PHASE: 'assessed-source-phase',
|
|
167
|
+
ASSESSED_BY_MODEL: 'assessed-by-model',
|
|
168
|
+
PREVIOUS_ASSESSMENT: 'risk-previous-assessment',
|
|
169
|
+
VALID_UNTIL: 'risk-valid-until',
|
|
170
|
+
SOURCE_DATA_CUTOFF: 'risk-source-data-cutoff',
|
|
171
|
+
ASSESSMENT_TRIGGER: 'risk-assessment-trigger',
|
|
172
|
+
METHOD_VERSION: 'risk-method-version',
|
|
173
|
+
MISSING_INFORMATION: 'risk-missing-information',
|
|
174
|
+
CHANGE_TYPE: 'risk-change-type',
|
|
175
|
+
CHANGE_DIRECTION: 'risk-change-direction',
|
|
176
|
+
CHANGE_MATERIAL: 'risk-change-material',
|
|
177
|
+
CHANGE_REASON: 'risk-change-reason',
|
|
178
|
+
CHANGE_NEW_INFO: 'risk-change-new-information',
|
|
179
|
+
CHANGE_RESOLVED_INFO: 'risk-change-resolved-information',
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
module.exports = {
|
|
183
|
+
PATIENT_EXT,
|
|
184
|
+
CONTEXT_EXT,
|
|
185
|
+
SYMPTOM_CASE_EXT,
|
|
186
|
+
RECOMMENDATION_EXT,
|
|
187
|
+
SAFETY_GATE_EXT,
|
|
188
|
+
MENTION_EXT,
|
|
189
|
+
ASSESSMENT_EXT,
|
|
190
|
+
GRADE_EXT,
|
|
191
|
+
ROUTING_EXT,
|
|
192
|
+
CLUSTER_EXT,
|
|
193
|
+
PALLIATIVE_EXT,
|
|
194
|
+
RISK_EXT,
|
|
195
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// the wording is matched on reconstruction — editing it strands already-stored resources
|
|
2
|
+
const GRADE_METHOD = Object.freeze({
|
|
3
|
+
proctcae_composite: 'PRO-CTCAE composite → CTCAE (unofficial approximation)',
|
|
4
|
+
agent_adjudicated: 'CTCAE grade scale applied to the reported findings',
|
|
5
|
+
carried_forward: 'Carried forward from the previous assessment',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const METHOD_TO_SOURCE = Object.freeze(Object.fromEntries(
|
|
9
|
+
Object.entries(GRADE_METHOD).map(([source, text]) => [text, source]),
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
module.exports = { GRADE_METHOD, METHOD_TO_SOURCE };
|
|
@@ -1,3 +1,71 @@
|
|
|
1
|
+
const PATIENT_SLUG = 'patient';
|
|
2
|
+
const ENCOUNTER_SLUG = 'encounter';
|
|
3
|
+
const CONTEXT_FACT_SLUG = 'context-fact';
|
|
1
4
|
const MENTION_SLUG = 'clinical-mention';
|
|
5
|
+
const RESULT_SLUG = 'patient-reported-result';
|
|
6
|
+
const ESCALATION_SLUG = 'dispatched-escalation';
|
|
7
|
+
const ESCALATION_KIND_SLUG = 'escalation-kind';
|
|
8
|
+
const ESCALATION_CASE_SLUG = 'escalation-case';
|
|
9
|
+
const ESCALATION_CASE_STATUS_SLUG = 'escalation-case-status';
|
|
10
|
+
const ESCALATION_DECISION_SLUG = 'escalation-decision';
|
|
11
|
+
const REMINDER_SLUG = 'reminder';
|
|
12
|
+
const REMINDER_KIND_SLUG = 'reminder-kind';
|
|
13
|
+
const COMMUNICATION_CHANNEL_SLUG = 'communication-channel';
|
|
14
|
+
const SYMPTOM_CASE_SLUG = 'symptom-condition';
|
|
15
|
+
const SYMPTOM_ASSESSMENT_SLUG = 'symptom-assessment';
|
|
16
|
+
const SYMPTOM_GRADE_SLUG = 'symptom-grade';
|
|
17
|
+
const PATIENT_RISK_SLUG = 'patient-risk-assessment';
|
|
18
|
+
const SAFETY_GATE_SLUG = 'recommendation-safety';
|
|
19
|
+
const RECOMMENDATION_PLAN_SLUG = 'recommendation-careplan';
|
|
20
|
+
const RECOMMENDATION_ELEMENTS_SLUG = 'recommendation-palliative';
|
|
21
|
+
const RECOMMENDATION_REC_SLUG = 'recommendation-rec';
|
|
22
|
+
const CONTINGENCY_PLAN_SLUG = 'contingency-plan';
|
|
23
|
+
const CONTINGENCY_STEP_SLUG = 'contingency-step';
|
|
24
|
+
const INTERVENTION_SLUG = 'intervention';
|
|
25
|
+
const INTERVENTION_OUTCOME_SLUG = 'intervention-outcome';
|
|
26
|
+
const INTERVENTION_KIND_SLUG = 'intervention-kind';
|
|
27
|
+
const CLUSTER_IMPRESSION_SLUG = 'cluster-impression';
|
|
28
|
+
const CLUSTER_LABEL_SLUG = 'cluster-label';
|
|
29
|
+
const ROUTING_ASSESSMENT_SLUG = 'routing-assessment';
|
|
30
|
+
const ROUTING_DISPOSITION_SLUG = 'routing-disposition';
|
|
31
|
+
const PALLIATIVE_ASSESSMENT_SLUG = 'palliative-assessment';
|
|
32
|
+
const PALLIATIVE_ESCALATION_SLUG = 'palliative-escalation';
|
|
33
|
+
const PALLIATIVE_CAREPLAN_SLUG = 'palliative-careplan';
|
|
34
|
+
const PALLIATIVE_CAREPLAN_REC_SLUG = 'palliative-careplan-rec';
|
|
2
35
|
|
|
3
|
-
module.exports = {
|
|
36
|
+
module.exports = {
|
|
37
|
+
PATIENT_SLUG,
|
|
38
|
+
ENCOUNTER_SLUG,
|
|
39
|
+
CONTEXT_FACT_SLUG,
|
|
40
|
+
MENTION_SLUG,
|
|
41
|
+
RESULT_SLUG,
|
|
42
|
+
ESCALATION_SLUG,
|
|
43
|
+
ESCALATION_KIND_SLUG,
|
|
44
|
+
ESCALATION_CASE_SLUG,
|
|
45
|
+
ESCALATION_CASE_STATUS_SLUG,
|
|
46
|
+
ESCALATION_DECISION_SLUG,
|
|
47
|
+
REMINDER_SLUG,
|
|
48
|
+
REMINDER_KIND_SLUG,
|
|
49
|
+
COMMUNICATION_CHANNEL_SLUG,
|
|
50
|
+
SYMPTOM_CASE_SLUG,
|
|
51
|
+
SYMPTOM_ASSESSMENT_SLUG,
|
|
52
|
+
SYMPTOM_GRADE_SLUG,
|
|
53
|
+
PATIENT_RISK_SLUG,
|
|
54
|
+
SAFETY_GATE_SLUG,
|
|
55
|
+
RECOMMENDATION_PLAN_SLUG,
|
|
56
|
+
RECOMMENDATION_ELEMENTS_SLUG,
|
|
57
|
+
RECOMMENDATION_REC_SLUG,
|
|
58
|
+
CONTINGENCY_PLAN_SLUG,
|
|
59
|
+
CONTINGENCY_STEP_SLUG,
|
|
60
|
+
INTERVENTION_SLUG,
|
|
61
|
+
INTERVENTION_OUTCOME_SLUG,
|
|
62
|
+
INTERVENTION_KIND_SLUG,
|
|
63
|
+
CLUSTER_IMPRESSION_SLUG,
|
|
64
|
+
CLUSTER_LABEL_SLUG,
|
|
65
|
+
ROUTING_ASSESSMENT_SLUG,
|
|
66
|
+
ROUTING_DISPOSITION_SLUG,
|
|
67
|
+
PALLIATIVE_ASSESSMENT_SLUG,
|
|
68
|
+
PALLIATIVE_ESCALATION_SLUG,
|
|
69
|
+
PALLIATIVE_CAREPLAN_SLUG,
|
|
70
|
+
PALLIATIVE_CAREPLAN_REC_SLUG,
|
|
71
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const DOCTOR = 'doctor';
|
|
2
|
+
const PATIENT = 'patient';
|
|
3
|
+
const UNKNOWN_ROLE = 'unknown';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_HALF_LIFE_DAYS = 365;
|
|
6
|
+
const NON_OWNER_TRUST_FACTOR = 0.5;
|
|
7
|
+
const CONFLICT_BAND = 0.5;
|
|
8
|
+
const MAX_ALTERNATES = 24;
|
|
9
|
+
const LEGACY_CONCEPT = 'ficha clinica';
|
|
10
|
+
|
|
11
|
+
const NO_KNOWN_ALLERGY = {
|
|
12
|
+
concept: 'sin alergias conocidas',
|
|
13
|
+
code: '716186003',
|
|
14
|
+
display: 'No known allergy',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const SOURCE_ROLES = {
|
|
18
|
+
specialist: DOCTOR, doctor: DOCTOR, oncologist: DOCTOR, auna: DOCTOR, note: DOCTOR, operator: DOCTOR, unit: DOCTOR,
|
|
19
|
+
'legacy-clinician': DOCTOR,
|
|
20
|
+
self: PATIENT, patient: PATIENT, chat: PATIENT,
|
|
21
|
+
'legacy-self': PATIENT,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const KIND_TO_RESOURCE_TYPE = {
|
|
25
|
+
condition: 'Condition',
|
|
26
|
+
observation: 'Observation',
|
|
27
|
+
medication: 'MedicationStatement',
|
|
28
|
+
procedure: 'Procedure',
|
|
29
|
+
allergy: 'AllergyIntolerance',
|
|
30
|
+
servicerequest: 'ServiceRequest',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const VARIABLE_REGISTRY = {
|
|
34
|
+
diagnosis_summary: { kind: 'condition', owner: DOCTOR, halfLifeDays: 365, singleton: true },
|
|
35
|
+
tumor_biology_summary: { kind: 'observation', owner: DOCTOR, halfLifeDays: DEFAULT_HALF_LIFE_DAYS, singleton: true },
|
|
36
|
+
injectable_onco_summary: { kind: 'medication', owner: DOCTOR, halfLifeDays: 21 },
|
|
37
|
+
oral_onco_summary: { kind: 'medication', owner: DOCTOR, halfLifeDays: 30 },
|
|
38
|
+
radiotherapy_summary: { kind: 'procedure', owner: DOCTOR, halfLifeDays: 30, singleton: true },
|
|
39
|
+
surgery_summary: { kind: 'procedure', owner: DOCTOR, halfLifeDays: 365 },
|
|
40
|
+
other_meds_summary: { kind: 'medication', owner: PATIENT, halfLifeDays: 30 },
|
|
41
|
+
comorbidities_summary: { kind: 'condition', owner: DOCTOR, halfLifeDays: 365 },
|
|
42
|
+
allergies_list: { kind: 'allergy', owner: DOCTOR, halfLifeDays: 3650 },
|
|
43
|
+
ecog_performance_status: { kind: 'observation', owner: DOCTOR, halfLifeDays: DEFAULT_HALF_LIFE_DAYS, singleton: true },
|
|
44
|
+
followup_plan_summary: { kind: 'servicerequest', owner: DOCTOR, halfLifeDays: DEFAULT_HALF_LIFE_DAYS, singleton: true },
|
|
45
|
+
intercurrent_events_summary: { kind: 'condition', owner: PATIENT, halfLifeDays: DEFAULT_HALF_LIFE_DAYS },
|
|
46
|
+
legacy_treatment_summary: { kind: 'medication', owner: DOCTOR, halfLifeDays: 30 },
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
UNKNOWN_ROLE,
|
|
51
|
+
DEFAULT_HALF_LIFE_DAYS,
|
|
52
|
+
NON_OWNER_TRUST_FACTOR,
|
|
53
|
+
CONFLICT_BAND,
|
|
54
|
+
MAX_ALTERNATES,
|
|
55
|
+
LEGACY_CONCEPT,
|
|
56
|
+
NO_KNOWN_ALLERGY,
|
|
57
|
+
SOURCE_ROLES,
|
|
58
|
+
KIND_TO_RESOURCE_TYPE,
|
|
59
|
+
VARIABLE_REGISTRY,
|
|
60
|
+
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
const { logger } = require('../../utils/logger');
|
|
2
2
|
const {
|
|
3
3
|
itemForQuestionId,
|
|
4
|
+
isSupplementaryQuestion,
|
|
5
|
+
isItemDimension,
|
|
4
6
|
canonicalAnswer,
|
|
5
7
|
affirmative,
|
|
6
8
|
standardOrdinal,
|
|
7
9
|
compositeGrade,
|
|
10
|
+
sentinelKind,
|
|
8
11
|
dimensionsFor,
|
|
9
12
|
} = require('./terminologyHelper');
|
|
10
13
|
|
|
@@ -17,44 +20,86 @@ function gradeComposites(catalog, input) {
|
|
|
17
20
|
const item = itemForQuestionId(catalog, questionId);
|
|
18
21
|
if (!item) continue;
|
|
19
22
|
const [term, dimension] = item;
|
|
20
|
-
if (!answersByTerm.has(term)) answersByTerm.set(term, {});
|
|
21
|
-
|
|
23
|
+
if (!answersByTerm.has(term)) answersByTerm.set(term, { own: {}, supplementary: {} });
|
|
24
|
+
const lane = isSupplementaryQuestion(catalog, questionId) ? 'supplementary' : 'own';
|
|
25
|
+
answersByTerm.get(term)[lane][dimension] = { label: String(canonicalAnswer(catalog, questionId, label)), raw: String(label) };
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
const pain = painDimensionAnswers(catalog, input.pain, input.triageId);
|
|
25
|
-
|
|
29
|
+
const lanes = [...answersByTerm]
|
|
30
|
+
.filter(([term]) => !(pain && term === PAIN_TERM))
|
|
31
|
+
.map(([term, answers]) => [term, splitSupplementary(catalog, term, answers)]);
|
|
32
|
+
if (pain) lanes.push([PAIN_TERM, { dimensionAnswers: pain, setAside: {} }]);
|
|
26
33
|
|
|
27
34
|
const graded = [];
|
|
28
|
-
for (const [term, dimensionAnswers] of
|
|
35
|
+
for (const [term, { dimensionAnswers, setAside }] of lanes) {
|
|
29
36
|
const ordinals = {};
|
|
30
37
|
for (const [dimension, label] of Object.entries(dimensionAnswers)) {
|
|
31
38
|
const ordinal = dimension === 'presence' ? presenceOrdinal(catalog, label) : standardOrdinal(catalog, dimension, label);
|
|
32
39
|
if (ordinal !== null) ordinals[dimension] = ordinal;
|
|
33
40
|
}
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
|
|
41
|
+
const resolved = resolveGrade(catalog, ordinals);
|
|
42
|
+
if (!resolved) {
|
|
43
|
+
// A sentinel is a real answer with no ordinal; only an unrecognised label is a defect.
|
|
44
|
+
const unexpected = Object.entries(dimensionAnswers)
|
|
45
|
+
.filter(([dimension, label]) => !sentinelKind(label)
|
|
46
|
+
&& (dimension === 'presence' ? presenceOrdinal(catalog, label) : standardOrdinal(catalog, dimension, label)) === null);
|
|
47
|
+
if (unexpected.length) {
|
|
48
|
+
logger.warn('[gradeComposites] answer outside the scale, symptom left unknown', {
|
|
49
|
+
term,
|
|
50
|
+
unexpected: Object.fromEntries(unexpected),
|
|
51
|
+
triageId: input.triageId,
|
|
52
|
+
});
|
|
53
|
+
} else if (Object.keys(ordinals).length) {
|
|
54
|
+
logger.warn('[gradeComposites] no composite for this combination, symptom left ungraded', {
|
|
55
|
+
term,
|
|
56
|
+
ordinals,
|
|
57
|
+
triageId: input.triageId,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const { grade, basis } = resolved;
|
|
63
|
+
if (basis === 'absence') {
|
|
64
|
+
logger.warn('[gradeComposites] graded outside the composite table', {
|
|
37
65
|
term,
|
|
38
66
|
ordinals,
|
|
39
67
|
dimensionAnswers,
|
|
68
|
+
basis,
|
|
69
|
+
grade,
|
|
40
70
|
triageId: input.triageId,
|
|
41
71
|
});
|
|
42
|
-
continue;
|
|
43
72
|
}
|
|
44
73
|
graded.push({
|
|
45
74
|
symptomId: `${input.triageId}-${term}`,
|
|
46
75
|
patientId: input.patientId,
|
|
47
76
|
term,
|
|
48
77
|
grade,
|
|
78
|
+
gradeBasis: basis,
|
|
49
79
|
effective: input.authored || null,
|
|
50
80
|
triageId: input.triageId,
|
|
51
81
|
dimensionAnswers: dimensionAnswers,
|
|
82
|
+
...(Object.keys(setAside).length ? { supplementaryAnswers: setAside } : {}),
|
|
52
83
|
source: 'triage',
|
|
53
84
|
});
|
|
54
85
|
}
|
|
55
86
|
return graded;
|
|
56
87
|
}
|
|
57
88
|
|
|
89
|
+
function splitSupplementary(catalog, term, { own, supplementary }) {
|
|
90
|
+
const dimensionAnswers = Object.fromEntries(Object.entries(own).map(([dimension, { label }]) => [dimension, label]));
|
|
91
|
+
const hasOwn = Object.keys(own).length > 0;
|
|
92
|
+
const setAside = {};
|
|
93
|
+
for (const [dimension, { label, raw }] of Object.entries(supplementary)) {
|
|
94
|
+
if (dimensionAnswers[dimension] == null && (isItemDimension(catalog, term, dimension) || !hasOwn)) {
|
|
95
|
+
dimensionAnswers[dimension] = label;
|
|
96
|
+
} else {
|
|
97
|
+
setAside[dimension] = raw;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { dimensionAnswers, setAside };
|
|
101
|
+
}
|
|
102
|
+
|
|
58
103
|
function presenceOrdinal(catalog, label) {
|
|
59
104
|
const ordinal = standardOrdinal(catalog, 'presence', label);
|
|
60
105
|
if (ordinal !== null) return ordinal;
|
|
@@ -78,11 +123,19 @@ function painDimensionAnswers(catalog, pain, triageId) {
|
|
|
78
123
|
}
|
|
79
124
|
|
|
80
125
|
function resolveGrade(catalog, ordinals) {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
126
|
+
const composite = compositeGrade(catalog, ordinals);
|
|
127
|
+
if (composite !== null) return { grade: composite, basis: 'composite' };
|
|
128
|
+
|
|
83
129
|
const dimensions = Object.keys(ordinals);
|
|
84
|
-
if (dimensions.length
|
|
85
|
-
|
|
130
|
+
if (dimensions.length === 1 && dimensions[0] === 'presence') {
|
|
131
|
+
return { grade: ordinals.presence > 0 ? 1 : 0, basis: 'presence' };
|
|
132
|
+
}
|
|
133
|
+
// An unknown is never a denial, so nothing resolved means nothing graded.
|
|
134
|
+
if (!dimensions.length) return null;
|
|
135
|
+
// Every code in the table with frequency 0 grades 0, so absence settles a contradiction.
|
|
136
|
+
if (ordinals.frequency === 0) return { grade: 0, basis: 'absence' };
|
|
137
|
+
// The published algorithm returns NA here; a lower-arity guess is wrong by up to two grades.
|
|
138
|
+
return null;
|
|
86
139
|
}
|
|
87
140
|
|
|
88
141
|
module.exports = { gradeComposites, PAIN_TERM };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { CONFLICT_BAND, NON_OWNER_TRUST_FACTOR, UNKNOWN_ROLE } = require('../constants/variableRegistry');
|
|
2
|
+
const { halfLifeDaysOf, ownerOf, sourceRole } = require('./variableRegistryHelper');
|
|
3
|
+
|
|
4
|
+
const MS_PER_DAY = 86400000;
|
|
5
|
+
const FLOOR_SOURCE_PREFIX = 'legacy-';
|
|
6
|
+
|
|
7
|
+
function isFloor({ source }) {
|
|
8
|
+
return String(source ?? '').trim().toLowerCase().startsWith(FLOOR_SOURCE_PREFIX);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function outranksFloor(claim, variableId) {
|
|
12
|
+
return !isFloor(claim) && sourceRole(claim.source) === ownerOf(variableId);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function ownershipFactor(source, variableId) {
|
|
16
|
+
return sourceRole(source) === ownerOf(variableId) ? 1 : NON_OWNER_TRUST_FACTOR;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Every comparison against NaN is false both ways, so an unreadable claim would win rather than lose.
|
|
20
|
+
function weightOf({ source, trust, validTime }, variableId, evaluatedAt) {
|
|
21
|
+
const elapsed = Date.parse(evaluatedAt) - Date.parse(validTime);
|
|
22
|
+
if (!Number.isFinite(elapsed) || !Number.isFinite(trust)) return 0;
|
|
23
|
+
const ageDays = Math.max(0, elapsed / MS_PER_DAY);
|
|
24
|
+
const weight = trust * ownershipFactor(source, variableId) * 2 ** (-ageDays / halfLifeDaysOf(variableId));
|
|
25
|
+
return Number.isFinite(weight) ? weight : 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function compareClaims(a, b, variableId, evaluatedAt) {
|
|
29
|
+
if (isFloor(a) !== isFloor(b) && outranksFloor(isFloor(a) ? b : a, variableId)) {
|
|
30
|
+
return isFloor(a) ? -1 : 1;
|
|
31
|
+
}
|
|
32
|
+
return weightOf(a, variableId, evaluatedAt) - weightOf(b, variableId, evaluatedAt);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isLiveConflict(alternate, winner, { variableId, evaluatedAt, winnerWeight }) {
|
|
36
|
+
const roles = [sourceRole(alternate.source), sourceRole(winner.source)];
|
|
37
|
+
if (roles[0] === roles[1] || roles.includes(UNKNOWN_ROLE)) return false;
|
|
38
|
+
return weightOf(alternate, variableId, evaluatedAt) >= CONFLICT_BAND * winnerWeight;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = { ownershipFactor, weightOf, isFloor, outranksFloor, compareClaims, isLiveConflict };
|