@peopl-health/nexus 5.71.16 → 5.71.17

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.
@@ -50,16 +50,21 @@ function nextLight(current, { service, color, source }) {
50
50
 
51
51
  const WEEKLY_COLLECTIVE_LIMIT = Object.freeze({ psychology: 1 });
52
52
 
53
+ // A patient in individual psycho-oncology therapy may join a group only when her psycho-oncology light is green, set by
54
+ // the AI or a specialist: the risk level decides, and no colour yet does not count as green.
53
55
  function collectiveOffer({
54
56
  service, color = 'unknown', isInvitationPaused = false, hasInvitationThisWeek = false,
55
- collectivesThisWeek = 0, hasCapacity = false,
57
+ collectivesThisWeek = 0, hasCapacity = false, isInIndividualTherapy = false,
58
+ psychologyColor = service === 'psychology' ? color : 'unknown',
56
59
  }) {
57
60
  assertLight(service, color);
61
+ assertLight('psychology', psychologyColor);
58
62
  const refuse = (reason) => ({ allowed: false, reason });
59
63
  if (color === 'red') return refuse('light_red');
60
64
  if (service === 'psychology' && color === 'orange') return refuse('light_orange');
61
65
  if (service === 'psychology' && color === 'unknown') return refuse('light_unconfirmed');
62
66
  if (isInvitationPaused) return refuse('invitation_paused');
67
+ if (isInIndividualTherapy && psychologyColor !== 'green') return refuse('individual_therapy');
63
68
  if (hasInvitationThisWeek) return refuse('already_invited_this_week');
64
69
  const limit = WEEKLY_COLLECTIVE_LIMIT[service];
65
70
  if (limit != null && collectivesThisWeek >= limit) return refuse('weekly_limit');
package/lib/index.d.ts CHANGED
@@ -942,7 +942,7 @@ declare module '@peopl-health/nexus' {
942
942
  export type SupportLightColor = 'green' | 'yellow' | 'orange' | 'red' | 'unknown';
943
943
  export type SupportLightSource = 'ai' | 'human';
944
944
  export type SupportLightOutcome = 'applied' | 'pending' | 'withdrawn' | 'unchanged';
945
- export type CollectiveRefusal = 'light_red' | 'light_orange' | 'light_unconfirmed' | 'invitation_paused'
945
+ export type CollectiveRefusal = 'light_red' | 'light_orange' | 'light_unconfirmed' | 'invitation_paused' | 'individual_therapy'
946
946
  | 'already_invited_this_week' | 'weekly_limit' | 'no_capacity';
947
947
 
948
948
  export interface SupportLightEvidence {
@@ -1044,6 +1044,8 @@ declare module '@peopl-health/nexus' {
1044
1044
  hasInvitationThisWeek?: boolean;
1045
1045
  collectivesThisWeek?: number;
1046
1046
  hasCapacity?: boolean;
1047
+ isInIndividualTherapy?: boolean;
1048
+ psychologyColor?: SupportLightColor;
1047
1049
  }): { allowed: boolean; reason: CollectiveRefusal | null };
1048
1050
  supportWeek(date: Date | string): string | null;
1049
1051
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.71.16",
3
+ "version": "5.71.17",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",