evo360-types 1.3.772 → 1.3.775

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.
@@ -183,6 +183,7 @@ exports.zAutomationOperatorSchema = zod_1.z.enum([
183
183
  // operator is NOT tied to `appointment.start_time` here (`fact` stays a free
184
184
  // string for forward compat); the evaluator returns false on any other fact and
185
185
  // the builder only offers these operators for the time fact.
186
+ // feat-311 F4 (D13): on `patient.age` the value is an age range instead.
186
187
  exports.zAutomationConditionSchema = zod_1.z
187
188
  .object({
188
189
  fact: zod_1.z.string().min(1),
@@ -192,7 +193,9 @@ exports.zAutomationConditionSchema = zod_1.z
192
193
  .superRefine((c, ctx) => {
193
194
  if (c.operator !== "between" && c.operator !== "not_between")
194
195
  return;
195
- const r = exports.zAutomationTimeOfDayRangeSchema.safeParse(c.value);
196
+ const r = c.fact === "patient.age"
197
+ ? exports.zAutomationAgeRangeSchema.safeParse(c.value)
198
+ : exports.zAutomationTimeOfDayRangeSchema.safeParse(c.value);
196
199
  if (!r.success) {
197
200
  for (const issue of r.error.issues) {
198
201
  ctx.addIssue({ ...issue, path: ["value", ...issue.path] });
@@ -202,6 +202,7 @@ export const zAutomationOperatorSchema = z.enum([
202
202
  // operator is NOT tied to `appointment.start_time` here (`fact` stays a free
203
203
  // string for forward compat); the evaluator returns false on any other fact and
204
204
  // the builder only offers these operators for the time fact.
205
+ // feat-311 F4 (D13): on `patient.age` the value is an age range instead.
205
206
  export const zAutomationConditionSchema = z
206
207
  .object({
207
208
  fact: z.string().min(1),
@@ -210,7 +211,10 @@ export const zAutomationConditionSchema = z
210
211
  })
211
212
  .superRefine((c, ctx) => {
212
213
  if (c.operator !== "between" && c.operator !== "not_between") return;
213
- const r = zAutomationTimeOfDayRangeSchema.safeParse(c.value);
214
+ const r =
215
+ c.fact === "patient.age"
216
+ ? zAutomationAgeRangeSchema.safeParse(c.value)
217
+ : zAutomationTimeOfDayRangeSchema.safeParse(c.value);
214
218
  if (!r.success) {
215
219
  for (const issue of r.error.issues) {
216
220
  ctx.addIssue({ ...issue, path: ["value", ...issue.path] });
package/dist/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export * from "./types/evo-reports";
39
39
  export * from "./types/evo-telemedicine";
40
40
  export * from "./types/evo-modules";
41
41
  export * from "./types/evo-docs";
42
+ export * from "./types/evo-emr";
42
43
  export * from "./apps/shared/zod-schemas";
43
44
  export * from "./apps/evo-core/zod-schemas";
44
45
  export * from "./apps/evo-core/nexus-claims";
package/dist/index.js CHANGED
@@ -56,6 +56,7 @@ __exportStar(require("./types/evo-reports"), exports);
56
56
  __exportStar(require("./types/evo-telemedicine"), exports);
57
57
  __exportStar(require("./types/evo-modules"), exports);
58
58
  __exportStar(require("./types/evo-docs"), exports);
59
+ __exportStar(require("./types/evo-emr"), exports);
59
60
  // zod schemas
60
61
  __exportStar(require("./apps/shared/zod-schemas"), exports);
61
62
  __exportStar(require("./apps/evo-core/zod-schemas"), exports);
package/dist/index.ts CHANGED
@@ -40,6 +40,7 @@ export * from "./types/evo-reports";
40
40
  export * from "./types/evo-telemedicine";
41
41
  export * from "./types/evo-modules";
42
42
  export * from "./types/evo-docs";
43
+ export * from "./types/evo-emr";
43
44
 
44
45
  // zod schemas
45
46
  export * from "./apps/shared/zod-schemas";
@@ -0,0 +1,19 @@
1
+ /** App do Firestore / namespace do módulo. */
2
+ export declare const EVO_EMR_APP = "evo-emr";
3
+ /**
4
+ * Chave em `tenants/{t}.modules` (catálogo `PLATFORM_MODULE_CATALOG`).
5
+ * Sem hífen: `MODULE_KEY_PATTERN` só aceita `[a-z][a-z0-9_]`.
6
+ */
7
+ export declare const EVO_EMR_MODULE_KEY = "emr";
8
+ /**
9
+ * Id do banco Firestore nomeado (criado com CMEK, D-004). O dado clínico NUNCA
10
+ * vai para o `(default)`; o backend abre um cliente próprio com este id.
11
+ */
12
+ export declare const EVO_EMR_DATABASE_ID = "evo-emr";
13
+ export declare const EvoEmrPermissions: {
14
+ /** Abrir o módulo e as instâncias de que o usuário é membro. */
15
+ readonly Access: "evo_emr_access";
16
+ /** Criar/ativar instâncias, vincular calendars e gerir membros (sem leitura clínica). */
17
+ readonly Admin: "evo_emr_admin";
18
+ };
19
+ export type EvoEmrPermissions = (typeof EvoEmrPermissions)[keyof typeof EvoEmrPermissions];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // evo-emr — prontuário eletrônico (feat-156).
3
+ //
4
+ // Só o "plumbing" de plataforma vive aqui (exceção explícita da D-019): id do
5
+ // app, chave do módulo no catálogo evo-modules, id do banco Firestore nomeado e
6
+ // as duas permissões tenant-level que o RBAC materializa em `perms`. Os
7
+ // contratos da API e do dado clínico NÃO entram neste pacote público; nascem em
8
+ // `@hubmedica/emr-contracts` (GitLab, privado).
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EvoEmrPermissions = exports.EVO_EMR_DATABASE_ID = exports.EVO_EMR_MODULE_KEY = exports.EVO_EMR_APP = void 0;
11
+ /** App do Firestore / namespace do módulo. */
12
+ exports.EVO_EMR_APP = "evo-emr";
13
+ /**
14
+ * Chave em `tenants/{t}.modules` (catálogo `PLATFORM_MODULE_CATALOG`).
15
+ * Sem hífen: `MODULE_KEY_PATTERN` só aceita `[a-z][a-z0-9_]`.
16
+ */
17
+ exports.EVO_EMR_MODULE_KEY = "emr";
18
+ /**
19
+ * Id do banco Firestore nomeado (criado com CMEK, D-004). O dado clínico NUNCA
20
+ * vai para o `(default)`; o backend abre um cliente próprio com este id.
21
+ */
22
+ exports.EVO_EMR_DATABASE_ID = "evo-emr";
23
+ // ----- Permissões tenant-level (grupo RBAC global `core/rbac/groups/evo-emr`)
24
+ exports.EvoEmrPermissions = {
25
+ /** Abrir o módulo e as instâncias de que o usuário é membro. */
26
+ Access: "evo_emr_access",
27
+ /** Criar/ativar instâncias, vincular calendars e gerir membros (sem leitura clínica). */
28
+ Admin: "evo_emr_admin",
29
+ };
@@ -0,0 +1,33 @@
1
+ // evo-emr — prontuário eletrônico (feat-156).
2
+ //
3
+ // Só o "plumbing" de plataforma vive aqui (exceção explícita da D-019): id do
4
+ // app, chave do módulo no catálogo evo-modules, id do banco Firestore nomeado e
5
+ // as duas permissões tenant-level que o RBAC materializa em `perms`. Os
6
+ // contratos da API e do dado clínico NÃO entram neste pacote público; nascem em
7
+ // `@hubmedica/emr-contracts` (GitLab, privado).
8
+
9
+ /** App do Firestore / namespace do módulo. */
10
+ export const EVO_EMR_APP = "evo-emr";
11
+
12
+ /**
13
+ * Chave em `tenants/{t}.modules` (catálogo `PLATFORM_MODULE_CATALOG`).
14
+ * Sem hífen: `MODULE_KEY_PATTERN` só aceita `[a-z][a-z0-9_]`.
15
+ */
16
+ export const EVO_EMR_MODULE_KEY = "emr";
17
+
18
+ /**
19
+ * Id do banco Firestore nomeado (criado com CMEK, D-004). O dado clínico NUNCA
20
+ * vai para o `(default)`; o backend abre um cliente próprio com este id.
21
+ */
22
+ export const EVO_EMR_DATABASE_ID = "evo-emr";
23
+
24
+ // ----- Permissões tenant-level (grupo RBAC global `core/rbac/groups/evo-emr`)
25
+ export const EvoEmrPermissions = {
26
+ /** Abrir o módulo e as instâncias de que o usuário é membro. */
27
+ Access: "evo_emr_access",
28
+ /** Criar/ativar instâncias, vincular calendars e gerir membros (sem leitura clínica). */
29
+ Admin: "evo_emr_admin",
30
+ } as const;
31
+
32
+ export type EvoEmrPermissions =
33
+ (typeof EvoEmrPermissions)[keyof typeof EvoEmrPermissions];
@@ -4,9 +4,11 @@ import type { IPlatformModuleDefinition } from "./index";
4
4
  * Mudou capability, passo, grupo ou métrica de algum módulo ⇒ incrementar: o
5
5
  * run antigo precisa dizer com que catálogo foi planejado.
6
6
  */
7
- export declare const PLATFORM_MODULE_CATALOG_VERSION = "2026-10-06.1";
7
+ export declare const PLATFORM_MODULE_CATALOG_VERSION = "2026-10-30.1";
8
8
  export declare const PLATFORM_MODULE_TELEMEDICINE = "telemedicine";
9
9
  export declare const PLATFORM_MODULE_CSQ = "csq";
10
+ /** feat-156 — prontuário eletrônico (chave sem hífen; app `evo-emr`). */
11
+ export declare const PLATFORM_MODULE_EMR = "emr";
10
12
  /**
11
13
  * Catálogo de módulos da plataforma (feat-263). É código, não Firestore: carrega
12
14
  * comportamento (passos, grupos, métricas) e precisa de versionamento e tipos.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLATFORM_MODULE_CATALOG = exports.PLATFORM_MODULE_CSQ = exports.PLATFORM_MODULE_TELEMEDICINE = exports.PLATFORM_MODULE_CATALOG_VERSION = void 0;
3
+ exports.PLATFORM_MODULE_CATALOG = exports.PLATFORM_MODULE_EMR = exports.PLATFORM_MODULE_CSQ = exports.PLATFORM_MODULE_TELEMEDICINE = exports.PLATFORM_MODULE_CATALOG_VERSION = void 0;
4
4
  exports.getModuleDefinition = getModuleDefinition;
5
5
  exports.listModuleDefinitions = listModuleDefinitions;
6
6
  exports.listModuleKeys = listModuleKeys;
@@ -12,9 +12,11 @@ exports.listDefaultTenantRbacGroups = listDefaultTenantRbacGroups;
12
12
  * Mudou capability, passo, grupo ou métrica de algum módulo ⇒ incrementar: o
13
13
  * run antigo precisa dizer com que catálogo foi planejado.
14
14
  */
15
- exports.PLATFORM_MODULE_CATALOG_VERSION = "2026-10-06.1";
15
+ exports.PLATFORM_MODULE_CATALOG_VERSION = "2026-10-30.1";
16
16
  exports.PLATFORM_MODULE_TELEMEDICINE = "telemedicine";
17
17
  exports.PLATFORM_MODULE_CSQ = "csq";
18
+ /** feat-156 — prontuário eletrônico (chave sem hífen; app `evo-emr`). */
19
+ exports.PLATFORM_MODULE_EMR = "emr";
18
20
  /**
19
21
  * Catálogo de módulos da plataforma (feat-263). É código, não Firestore: carrega
20
22
  * comportamento (passos, grupos, métricas) e precisa de versionamento e tipos.
@@ -76,6 +78,39 @@ exports.PLATFORM_MODULE_CATALOG = {
76
78
  disable: ["entitlement"],
77
79
  },
78
80
  },
81
+ emr: {
82
+ key: exports.PLATFORM_MODULE_EMR,
83
+ label: "Prontuário eletrônico (evo-emr)",
84
+ description: "Consultas, perfil clínico e documentos médicos por instância, com entrega ao paciente pelo /qr.",
85
+ app_id: "evo-emr",
86
+ // `instances` é a alavanca comercial da Etapa 1 (quantas instâncias o tenant
87
+ // pode ter) enquanto a métrica `emr_instances` não existe no FinOps.
88
+ // `memed`/`delivery` gateiam as rotas das Etapas 2–3 via
89
+ // `requireTenantModule('emr', { capability })`.
90
+ capabilities: {
91
+ instances: { label: "Instâncias incluídas", default: 1 },
92
+ memed: { label: "Prescrição Memed", default: true },
93
+ delivery: { label: "Entrega de documentos ao paciente", default: true },
94
+ },
95
+ // `manual` até a métrica de instâncias entrar no contrato (feat-263 F4 /
96
+ // feat-150): não há sincronia contrato→entitlement a prometer ainda.
97
+ default_entitlement: { status: "active", source: "manual" },
98
+ default_for_new_tenants: false,
99
+ rbac_groups: ["evo-emr"],
100
+ allowance_metrics: [],
101
+ rollout: {
102
+ path: "platform/evo-modules/rollout/emr",
103
+ layout: "flags_map",
104
+ flags: { api: "api_enabled", instances: "instances_enabled" },
105
+ },
106
+ depends_on: [],
107
+ provisioning: {
108
+ // O grupo RBAC fica no disable, como na telemedicina (Q7): desligar o
109
+ // módulo não apaga papel de ninguém.
110
+ enable: ["entitlement", "rbac_group", "rbac_recompute", "rollout_check"],
111
+ disable: ["entitlement"],
112
+ },
113
+ },
79
114
  };
80
115
  function getModuleDefinition(key) {
81
116
  if (!key || typeof key !== "string")
@@ -5,10 +5,12 @@ import type { IPlatformModuleDefinition } from "./index";
5
5
  * Mudou capability, passo, grupo ou métrica de algum módulo ⇒ incrementar: o
6
6
  * run antigo precisa dizer com que catálogo foi planejado.
7
7
  */
8
- export const PLATFORM_MODULE_CATALOG_VERSION = "2026-10-06.1";
8
+ export const PLATFORM_MODULE_CATALOG_VERSION = "2026-10-30.1";
9
9
 
10
10
  export const PLATFORM_MODULE_TELEMEDICINE = "telemedicine";
11
11
  export const PLATFORM_MODULE_CSQ = "csq";
12
+ /** feat-156 — prontuário eletrônico (chave sem hífen; app `evo-emr`). */
13
+ export const PLATFORM_MODULE_EMR = "emr";
12
14
 
13
15
  /**
14
16
  * Catálogo de módulos da plataforma (feat-263). É código, não Firestore: carrega
@@ -73,6 +75,40 @@ export const PLATFORM_MODULE_CATALOG: Readonly<Record<string, IPlatformModuleDef
73
75
  disable: ["entitlement"],
74
76
  },
75
77
  },
78
+ emr: {
79
+ key: PLATFORM_MODULE_EMR,
80
+ label: "Prontuário eletrônico (evo-emr)",
81
+ description:
82
+ "Consultas, perfil clínico e documentos médicos por instância, com entrega ao paciente pelo /qr.",
83
+ app_id: "evo-emr",
84
+ // `instances` é a alavanca comercial da Etapa 1 (quantas instâncias o tenant
85
+ // pode ter) enquanto a métrica `emr_instances` não existe no FinOps.
86
+ // `memed`/`delivery` gateiam as rotas das Etapas 2–3 via
87
+ // `requireTenantModule('emr', { capability })`.
88
+ capabilities: {
89
+ instances: { label: "Instâncias incluídas", default: 1 },
90
+ memed: { label: "Prescrição Memed", default: true },
91
+ delivery: { label: "Entrega de documentos ao paciente", default: true },
92
+ },
93
+ // `manual` até a métrica de instâncias entrar no contrato (feat-263 F4 /
94
+ // feat-150): não há sincronia contrato→entitlement a prometer ainda.
95
+ default_entitlement: { status: "active", source: "manual" },
96
+ default_for_new_tenants: false,
97
+ rbac_groups: ["evo-emr"],
98
+ allowance_metrics: [],
99
+ rollout: {
100
+ path: "platform/evo-modules/rollout/emr",
101
+ layout: "flags_map",
102
+ flags: { api: "api_enabled", instances: "instances_enabled" },
103
+ },
104
+ depends_on: [],
105
+ provisioning: {
106
+ // O grupo RBAC fica no disable, como na telemedicina (Q7): desligar o
107
+ // módulo não apaga papel de ninguém.
108
+ enable: ["entitlement", "rbac_group", "rbac_recompute", "rollout_check"],
109
+ disable: ["entitlement"],
110
+ },
111
+ },
76
112
  };
77
113
 
78
114
  export function getModuleDefinition(key: string | null | undefined): IPlatformModuleDefinition | null {
@@ -102,11 +102,11 @@ export interface IAutomationFilterValues {
102
102
  status_bases: string[];
103
103
  appointment_types: string[];
104
104
  }
105
- export declare const AUTOMATION_APPOINTMENT_FACTS: readonly ["appointment.status", "appointment.status_base", "appointment.appointment_type", "appointment.appointment_base_type", "appointment.appointment_mode", "appointment.professional_id", "appointment.procedure_ids", "appointment.professional_name", "appointment.procedure_names", "appointment.insurance_name", "appointment.address_name", "appointment.payment_status", "appointment.calendar_id", "appointment.start_time"];
105
+ export declare const AUTOMATION_APPOINTMENT_FACTS: readonly ["appointment.status", "appointment.status_base", "appointment.appointment_type", "appointment.appointment_base_type", "appointment.appointment_mode", "appointment.professional_id", "appointment.procedure_ids", "appointment.professional_name", "appointment.procedure_names", "appointment.insurance_name", "appointment.address_name", "appointment.payment_status", "appointment.calendar_id", "appointment.start_time", "patient.sex", "patient.age"];
106
106
  export type AutomationAppointmentFact = (typeof AUTOMATION_APPOINTMENT_FACTS)[number];
107
107
  export declare const AUTOMATION_LEAD_FACTS: readonly ["lead.status", "lead.qualification_code", "lead.qualification_name", "lead.qualification_funnel_level", "lead.dist_channel_code", "lead.dist_channel_name", "lead.tags"];
108
108
  export type AutomationLeadFact = (typeof AUTOMATION_LEAD_FACTS)[number];
109
- export declare const AUTOMATION_PATIENT_FACTS: readonly ["patient.status", "patient.source_code", "patient.source_name", "patient.tags"];
109
+ export declare const AUTOMATION_PATIENT_FACTS: readonly ["patient.status", "patient.source_code", "patient.source_name", "patient.tags", "patient.sex", "patient.age"];
110
110
  export type AutomationPatientFact = (typeof AUTOMATION_PATIENT_FACTS)[number];
111
111
  export type AutomationFact = AutomationAppointmentFact | AutomationLeadFact | AutomationPatientFact;
112
112
  export declare const AutomationOperatorEnum: {
@@ -39,7 +39,8 @@ exports.HubAutomationPermissions = {
39
39
  Write: "hub_automation_write",
40
40
  };
41
41
  // ------------------------------------------------------
42
- // Fact catalog (F1: appointment domain facts only — Q15: no patient.* facts)
42
+ // Fact catalog (F1: appointment domain facts; feat-311 F4: + patient.sex /
43
+ // patient.age, read from the PATIENT doc only when a branch uses them)
43
44
  // ------------------------------------------------------
44
45
  exports.AUTOMATION_APPOINTMENT_FACTS = [
45
46
  "appointment.status",
@@ -64,6 +65,13 @@ exports.AUTOMATION_APPOINTMENT_FACTS = [
64
65
  // feat-167: "HH:mm" local of startDate in the TENANT timezone (same clock as
65
66
  // selection.time_range). Meant for the between/not_between operators.
66
67
  "appointment.start_time",
68
+ // feat-311 F4 (D12/D13): patient facts on appointment targets. Normalized
69
+ // 'female' | 'male' | 'other'; age = full years on the appointment's local
70
+ // date. Absence is strict: without the data no operator matches except
71
+ // exists/not_exists.
72
+ "patient.sex",
73
+ // between/not_between with an IAutomationAgeRange value ({min?, max?}, inclusive).
74
+ "patient.age",
67
75
  ];
68
76
  // feat-085 (F3): lead domain facts (derived from the fields ILead exposes;
69
77
  // resolved from the event-preloaded lead). Mirror of the appointment catalog.
@@ -87,6 +95,11 @@ exports.AUTOMATION_PATIENT_FACTS = [
87
95
  "patient.source_name",
88
96
  // string[] of tag names — matches if ANY tag name matches.
89
97
  "patient.tags",
98
+ // feat-311 F4: same semantics as in AUTOMATION_APPOINTMENT_FACTS. Reference
99
+ // date for the age: the birthday (age being completed) on the birthday
100
+ // routine; the event date on domain-event routines.
101
+ "patient.sex",
102
+ "patient.age",
90
103
  ];
91
104
  // ------------------------------------------------------
92
105
  // Conditions (recursive AND/OR groups)
@@ -238,7 +238,8 @@ export interface IAutomationFilterValues {
238
238
  }
239
239
 
240
240
  // ------------------------------------------------------
241
- // Fact catalog (F1: appointment domain facts only — Q15: no patient.* facts)
241
+ // Fact catalog (F1: appointment domain facts; feat-311 F4: + patient.sex /
242
+ // patient.age, read from the PATIENT doc only when a branch uses them)
242
243
  // ------------------------------------------------------
243
244
  export const AUTOMATION_APPOINTMENT_FACTS = [
244
245
  "appointment.status",
@@ -263,6 +264,13 @@ export const AUTOMATION_APPOINTMENT_FACTS = [
263
264
  // feat-167: "HH:mm" local of startDate in the TENANT timezone (same clock as
264
265
  // selection.time_range). Meant for the between/not_between operators.
265
266
  "appointment.start_time",
267
+ // feat-311 F4 (D12/D13): patient facts on appointment targets. Normalized
268
+ // 'female' | 'male' | 'other'; age = full years on the appointment's local
269
+ // date. Absence is strict: without the data no operator matches except
270
+ // exists/not_exists.
271
+ "patient.sex",
272
+ // between/not_between with an IAutomationAgeRange value ({min?, max?}, inclusive).
273
+ "patient.age",
266
274
  ] as const;
267
275
 
268
276
  export type AutomationAppointmentFact =
@@ -293,6 +301,11 @@ export const AUTOMATION_PATIENT_FACTS = [
293
301
  "patient.source_name",
294
302
  // string[] of tag names — matches if ANY tag name matches.
295
303
  "patient.tags",
304
+ // feat-311 F4: same semantics as in AUTOMATION_APPOINTMENT_FACTS. Reference
305
+ // date for the age: the birthday (age being completed) on the birthday
306
+ // routine; the event date on domain-event routines.
307
+ "patient.sex",
308
+ "patient.age",
296
309
  ] as const;
297
310
 
298
311
  export type AutomationPatientFact = (typeof AUTOMATION_PATIENT_FACTS)[number];
@@ -336,7 +349,9 @@ export interface IAutomationCondition {
336
349
  fact: string;
337
350
  operator: AutomationOperator;
338
351
  // Not required for unary operators (exists/not_exists/is_true/is_false).
339
- // between/not_between require an IAutomationTimeOfDayRange (feat-167).
352
+ // between/not_between: IAutomationAgeRange ({min?, max?}, inclusive full
353
+ // years) when fact === "patient.age" (feat-311 F4); otherwise an
354
+ // IAutomationTimeOfDayRange (feat-167, appointment.start_time).
340
355
  value?: unknown;
341
356
  }
342
357
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evo360-types",
3
- "version": "1.3.772",
3
+ "version": "1.3.775",
4
4
  "description": "HREVO360 Shared Types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",