tychat-contracts 1.6.21 → 1.6.24

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.
Files changed (118) hide show
  1. package/README.md +33 -33
  2. package/dist/storage/delete-object-rpc.dto.d.ts +9 -0
  3. package/dist/storage/delete-object-rpc.dto.d.ts.map +1 -0
  4. package/dist/storage/delete-object-rpc.dto.js +48 -0
  5. package/dist/storage/index.d.ts +1 -0
  6. package/dist/storage/index.d.ts.map +1 -1
  7. package/dist/storage/index.js +1 -0
  8. package/dist/storage/storage-rmq-patterns.d.ts +2 -0
  9. package/dist/storage/storage-rmq-patterns.d.ts.map +1 -1
  10. package/dist/storage/storage-rmq-patterns.js +3 -1
  11. package/jest.config.ts +5 -5
  12. package/package.json +2 -1
  13. package/src/ai/ai-usage-response.dto.ts +47 -47
  14. package/src/ai/create-ai-usage.dto.ts +43 -43
  15. package/src/analytics/analytics-emitter.helper.ts +54 -54
  16. package/src/analytics/analytics-query.dto.ts +222 -222
  17. package/src/analytics/create-analytic-event.dto.ts +85 -85
  18. package/src/analytics/event-analytic.enum.ts +119 -119
  19. package/src/appointments/appointment-procedure.dto.ts +76 -76
  20. package/src/appointments/create-appointment.dto.ts +153 -153
  21. package/src/appointments/index.ts +10 -10
  22. package/src/appointments/list-appointments-query.dto.ts +157 -157
  23. package/src/appointments/update-appointment-procedure.dto.ts +10 -10
  24. package/src/appointments/update-appointment.dto.ts +4 -4
  25. package/src/auth/refresh-token.dto.ts +10 -10
  26. package/src/billing/billing-response.dto.ts +68 -68
  27. package/src/billing/create-billing.dto.ts +70 -70
  28. package/src/billing/index.ts +6 -6
  29. package/src/billing/list-billings-query.dto.ts +61 -61
  30. package/src/billing/update-billing.dto.ts +4 -4
  31. package/src/cashback/cashback-balance-response.dto.ts +33 -33
  32. package/src/cashback/cashback-config-response.dto.ts +43 -43
  33. package/src/cashback/cashback-enums.ts +33 -33
  34. package/src/cashback/cashback-kafka-payloads.ts +102 -102
  35. package/src/cashback/cashback-kafka-topics.ts +23 -23
  36. package/src/cashback/index.ts +7 -7
  37. package/src/cashback/referral-code-response.dto.ts +49 -49
  38. package/src/cashback/use-referral-code-response.dto.ts +15 -15
  39. package/src/configurations/clinic-configuration.dto.ts +39 -39
  40. package/src/configurations/opening-hours-slot.dto.ts +41 -41
  41. package/src/configurations/update-clinic-configuration.dto.ts +39 -39
  42. package/src/connections/whatsapp-official.dto.ts +113 -113
  43. package/src/conversations/conversation-contact-filters-query.validator.spec.ts +221 -221
  44. package/src/conversations/conversation-contact-filters-query.validator.ts +10 -10
  45. package/src/conversations/conversation-intention.dto.ts +24 -24
  46. package/src/conversations/conversation-response.dto.ts +69 -69
  47. package/src/conversations/conversation-session-response.dto.ts +65 -65
  48. package/src/conversations/conversation-type.dto.ts +15 -15
  49. package/src/conversations/create-conversation-session.dto.ts +28 -28
  50. package/src/conversations/create-conversation.dto.ts +69 -69
  51. package/src/conversations/followup-config-response.dto.ts +290 -290
  52. package/src/conversations/followup-log-response.dto.ts +58 -58
  53. package/src/conversations/followup-type.dto.ts +22 -22
  54. package/src/conversations/index.ts +17 -17
  55. package/src/conversations/list-conversation-contacts-filters.dto.ts +15 -15
  56. package/src/conversations/list-conversation-contacts-query.dto.ts +81 -81
  57. package/src/conversations/satisfaction-response.dto.ts +116 -116
  58. package/src/filters/index.ts +1 -1
  59. package/src/filters/parsed-filter.dto.ts +41 -41
  60. package/src/index.ts +23 -23
  61. package/src/patients/create-patient.dto.ts +122 -122
  62. package/src/patients/index.ts +10 -10
  63. package/src/patients/list-patients-filters.dto.ts +15 -15
  64. package/src/patients/list-patients-query.dto.ts +61 -61
  65. package/src/patients/patient-document-response.dto.ts +33 -33
  66. package/src/patients/patient-history-entry.dto.ts +22 -22
  67. package/src/patients/patient-status.dto.ts +9 -9
  68. package/src/patients/update-patient-document.dto.ts +10 -10
  69. package/src/patients/update-patient.dto.ts +15 -15
  70. package/src/payment-gateway/create-gateway-payment.dto.ts +123 -123
  71. package/src/payment-gateway/gateway-payment-response.dto.ts +65 -65
  72. package/src/payment-gateway/index.ts +12 -12
  73. package/src/payment-gateway/list-gateway-payments-query.dto.ts +63 -63
  74. package/src/payment-gateway/payment-gateway-kafka-topics.ts +25 -25
  75. package/src/payment-gateway/payment-gateway.enums.ts +34 -34
  76. package/src/payment-gateway/update-gateway-payment.dto.ts +7 -7
  77. package/src/payment-gateway/webhook-payload.dto.ts +32 -32
  78. package/src/payments/create-payment.dto.ts +73 -73
  79. package/src/payments/index.ts +6 -6
  80. package/src/payments/list-payments-query.dto.ts +44 -44
  81. package/src/payments/payment-response.dto.ts +67 -67
  82. package/src/payments/update-payment.dto.ts +4 -4
  83. package/src/procedures/create-procedure.dto.ts +104 -104
  84. package/src/procedures/index.ts +6 -6
  85. package/src/procedures/list-procedures-query.dto.ts +59 -59
  86. package/src/procedures/update-procedure.dto.ts +4 -4
  87. package/src/storage/delete-object-rpc.dto.ts +28 -0
  88. package/src/storage/index.ts +1 -0
  89. package/src/storage/storage-rmq-patterns.ts +3 -0
  90. package/src/tenants/index.ts +10 -10
  91. package/src/tenants/whatsapp-provider-kind.dto.ts +12 -12
  92. package/dist/analytics/should-skip-analytics-tenant-lookup.d.ts +0 -7
  93. package/dist/analytics/should-skip-analytics-tenant-lookup.d.ts.map +0 -1
  94. package/dist/analytics/should-skip-analytics-tenant-lookup.js +0 -13
  95. package/dist/appointments/opening-hours-slot.dto.d.ts +0 -6
  96. package/dist/appointments/opening-hours-slot.dto.d.ts.map +0 -1
  97. package/dist/appointments/opening-hours-slot.dto.js +0 -2
  98. package/dist/patients/patient-procedure.dto.d.ts +0 -9
  99. package/dist/patients/patient-procedure.dto.d.ts.map +0 -1
  100. package/dist/patients/patient-procedure.dto.js +0 -79
  101. package/dist/patients/update-patient-procedure.dto.d.ts +0 -6
  102. package/dist/patients/update-patient-procedure.dto.d.ts.map +0 -1
  103. package/dist/patients/update-patient-procedure.dto.js +0 -8
  104. package/dist/payments/payment.dto.d.ts +0 -15
  105. package/dist/payments/payment.dto.d.ts.map +0 -1
  106. package/dist/payments/payment.dto.js +0 -2
  107. package/dist/tenants/create-tenant.dto.d.ts +0 -10
  108. package/dist/tenants/create-tenant.dto.d.ts.map +0 -1
  109. package/dist/tenants/create-tenant.dto.js +0 -73
  110. package/dist/tenants/tenant-slug.util.spec.d.ts +0 -2
  111. package/dist/tenants/tenant-slug.util.spec.d.ts.map +0 -1
  112. package/dist/tenants/tenant-slug.util.spec.js +0 -102
  113. package/dist/tenants/update-tenant-payload.dto.d.ts +0 -6
  114. package/dist/tenants/update-tenant-payload.dto.d.ts.map +0 -1
  115. package/dist/tenants/update-tenant-payload.dto.js +0 -25
  116. package/dist/tenants/update-tenant.dto.d.ts +0 -10
  117. package/dist/tenants/update-tenant.dto.d.ts.map +0 -1
  118. package/dist/tenants/update-tenant.dto.js +0 -78
@@ -1,41 +1,41 @@
1
- /**
2
- * Valid filter operators for query filters.
3
- *
4
- * - `==` : Equality
5
- * - `!=` : Inequality
6
- * - `>` : Greater than
7
- * - `<` : Less than
8
- * - `>=` : Greater than or equal
9
- * - `<=` : Less than or equal
10
- * - `in` : Value is one of the elements in the array
11
- * - `like` : SQL `LIKE` (value must be a string pattern, e.g. `%foo%`)
12
- * - `unlike` : SQL `NOT LIKE` (value must be a string pattern)
13
- */
14
- export const VALID_FILTER_OPS = [
15
- '==',
16
- '!=',
17
- '>',
18
- '<',
19
- '>=',
20
- '<=',
21
- 'in',
22
- 'like',
23
- 'unlike',
24
- ] as const;
25
- export type FilterOp = (typeof VALID_FILTER_OPS)[number];
26
-
27
- /**
28
- * Generic parsed filter object.
29
- *
30
- * Sent from the API gateway to microservices after validation.
31
- * Each microservice is responsible for checking whether `key` is
32
- * a valid column on its entity before applying the filter.
33
- */
34
- export interface ParsedFilterDto {
35
- /** Column name (camelCase, must map to a real entity column in the microservice). */
36
- key: string;
37
- /** Comparison operator. */
38
- op: FilterOp;
39
- /** Scalar value (string | number), array for `in`, or string pattern for `like` / `unlike`. */
40
- value: string | number | (string | number)[];
41
- }
1
+ /**
2
+ * Valid filter operators for query filters.
3
+ *
4
+ * - `==` : Equality
5
+ * - `!=` : Inequality
6
+ * - `>` : Greater than
7
+ * - `<` : Less than
8
+ * - `>=` : Greater than or equal
9
+ * - `<=` : Less than or equal
10
+ * - `in` : Value is one of the elements in the array
11
+ * - `like` : SQL `LIKE` (value must be a string pattern, e.g. `%foo%`)
12
+ * - `unlike` : SQL `NOT LIKE` (value must be a string pattern)
13
+ */
14
+ export const VALID_FILTER_OPS = [
15
+ '==',
16
+ '!=',
17
+ '>',
18
+ '<',
19
+ '>=',
20
+ '<=',
21
+ 'in',
22
+ 'like',
23
+ 'unlike',
24
+ ] as const;
25
+ export type FilterOp = (typeof VALID_FILTER_OPS)[number];
26
+
27
+ /**
28
+ * Generic parsed filter object.
29
+ *
30
+ * Sent from the API gateway to microservices after validation.
31
+ * Each microservice is responsible for checking whether `key` is
32
+ * a valid column on its entity before applying the filter.
33
+ */
34
+ export interface ParsedFilterDto {
35
+ /** Column name (camelCase, must map to a real entity column in the microservice). */
36
+ key: string;
37
+ /** Comparison operator. */
38
+ op: FilterOp;
39
+ /** Scalar value (string | number), array for `in`, or string pattern for `like` / `unlike`. */
40
+ value: string | number | (string | number)[];
41
+ }
package/src/index.ts CHANGED
@@ -1,23 +1,23 @@
1
- export * from './appointments';
2
- export * from './auth';
3
- export * from './users';
4
- export * from './patients';
5
- export * from './procedures';
6
- export * from './configurations';
7
- export * from './specialties';
8
- export * from './professionals';
9
- export * from './payments';
10
- export * from './billing';
11
- export * from './payment-gateway';
12
- export * from './ai';
13
- export * from './storage';
14
- export * from './notifications';
15
- export * from './tenants';
16
- export * from './conversations';
17
- export * from './connections';
18
- export * from './analytics';
19
- export * from './cashback';
20
- export * from './filters';
21
- export * from './anamneses';
22
- export * from './legal-terms';
23
- export * from './panel-rbac';
1
+ export * from './appointments';
2
+ export * from './auth';
3
+ export * from './users';
4
+ export * from './patients';
5
+ export * from './procedures';
6
+ export * from './configurations';
7
+ export * from './specialties';
8
+ export * from './professionals';
9
+ export * from './payments';
10
+ export * from './billing';
11
+ export * from './payment-gateway';
12
+ export * from './ai';
13
+ export * from './storage';
14
+ export * from './notifications';
15
+ export * from './tenants';
16
+ export * from './conversations';
17
+ export * from './connections';
18
+ export * from './analytics';
19
+ export * from './cashback';
20
+ export * from './filters';
21
+ export * from './anamneses';
22
+ export * from './legal-terms';
23
+ export * from './panel-rbac';
@@ -1,122 +1,122 @@
1
- import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
- import {
3
- IsBoolean,
4
- IsDateString,
5
- IsEmail,
6
- IsNotEmpty,
7
- IsOptional,
8
- IsString,
9
- Length,
10
- MaxLength,
11
- } from 'class-validator';
12
- import { Transform } from 'class-transformer';
13
-
14
- export class CreatePatientDto {
15
- @ApiProperty({
16
- description: 'Nome completo do paciente',
17
- example: 'João da Silva',
18
- maxLength: 255,
19
- })
20
- @IsString()
21
- @IsNotEmpty()
22
- @MaxLength(255)
23
- name: string;
24
-
25
- @ApiProperty({
26
- description: 'CPF do paciente apenas com dígitos',
27
- example: '12345678909',
28
- minLength: 11,
29
- maxLength: 11,
30
- })
31
- @IsString()
32
- @Length(11, 11, { message: 'cpf deve conter exatamente 11 dígitos' })
33
- cpf: string;
34
-
35
- @ApiProperty({
36
- description: 'Data de nascimento do paciente no formato ISO (YYYY-MM-DD)',
37
- example: '1990-01-01',
38
- })
39
- @IsDateString()
40
- birthDate: string;
41
-
42
- @ApiPropertyOptional({
43
- description: 'E-mail do paciente',
44
- example: 'joao.silva@email.com',
45
- maxLength: 255,
46
- })
47
- @IsOptional()
48
- @IsEmail({}, { message: 'email deve ser um e-mail válido' })
49
- @MaxLength(255)
50
- email?: string | null;
51
-
52
- @ApiPropertyOptional({
53
- description: 'Telefone de contato do paciente',
54
- example: '+55 11 99999-9999',
55
- maxLength: 30,
56
- })
57
- @IsString()
58
- @IsOptional()
59
- @MaxLength(30)
60
- phone?: string | null;
61
-
62
- @ApiPropertyOptional({
63
- description: 'Gênero do paciente',
64
- example: 'masculino',
65
- maxLength: 50,
66
- })
67
- @IsString()
68
- @IsOptional()
69
- @MaxLength(50)
70
- gender?: string | null;
71
-
72
- @ApiPropertyOptional({
73
- description: 'Endereço completo do paciente',
74
- example: 'Rua Exemplo, 123 - São Paulo/SP',
75
- maxLength: 500,
76
- })
77
- @IsString()
78
- @IsOptional()
79
- @MaxLength(500)
80
- address?: string | null;
81
-
82
- @ApiProperty({
83
- description: 'Indica se o paciente possui alguma deficiência',
84
- example: true,
85
- })
86
- @IsBoolean()
87
- hasDisability: boolean;
88
-
89
- @ApiPropertyOptional({
90
- description:
91
- 'Descrição da deficiência do paciente (obrigatório quando hasDisability for true)',
92
- example: 'Deficiência visual',
93
- maxLength: 500,
94
- })
95
- @IsString()
96
- @IsOptional()
97
- @MaxLength(500)
98
- disabilityDescription?: string | null;
99
-
100
- @ApiPropertyOptional({
101
- description: 'Observação inicial do paciente (opcional)',
102
- example: 'Paciente chegou com queixa de dor nas costas',
103
- maxLength: 2000,
104
- })
105
- @IsString()
106
- @IsOptional()
107
- @MaxLength(2000)
108
- initialObservation?: string | null;
109
-
110
- @ApiPropertyOptional({
111
- description:
112
- 'Nova observação do paciente (cria uma entrada de histórico de observações)',
113
- example: 'Paciente tem alergia a penicilina',
114
- maxLength: 2000,
115
- })
116
- @IsString()
117
- @IsOptional()
118
- @MaxLength(2000)
119
- @Transform(({ value, obj }) => value ?? obj.notes ?? obj.observation)
120
- observation?: string | null;
121
- }
122
-
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import {
3
+ IsBoolean,
4
+ IsDateString,
5
+ IsEmail,
6
+ IsNotEmpty,
7
+ IsOptional,
8
+ IsString,
9
+ Length,
10
+ MaxLength,
11
+ } from 'class-validator';
12
+ import { Transform } from 'class-transformer';
13
+
14
+ export class CreatePatientDto {
15
+ @ApiProperty({
16
+ description: 'Nome completo do paciente',
17
+ example: 'João da Silva',
18
+ maxLength: 255,
19
+ })
20
+ @IsString()
21
+ @IsNotEmpty()
22
+ @MaxLength(255)
23
+ name: string;
24
+
25
+ @ApiProperty({
26
+ description: 'CPF do paciente apenas com dígitos',
27
+ example: '12345678909',
28
+ minLength: 11,
29
+ maxLength: 11,
30
+ })
31
+ @IsString()
32
+ @Length(11, 11, { message: 'cpf deve conter exatamente 11 dígitos' })
33
+ cpf: string;
34
+
35
+ @ApiProperty({
36
+ description: 'Data de nascimento do paciente no formato ISO (YYYY-MM-DD)',
37
+ example: '1990-01-01',
38
+ })
39
+ @IsDateString()
40
+ birthDate: string;
41
+
42
+ @ApiPropertyOptional({
43
+ description: 'E-mail do paciente',
44
+ example: 'joao.silva@email.com',
45
+ maxLength: 255,
46
+ })
47
+ @IsOptional()
48
+ @IsEmail({}, { message: 'email deve ser um e-mail válido' })
49
+ @MaxLength(255)
50
+ email?: string | null;
51
+
52
+ @ApiPropertyOptional({
53
+ description: 'Telefone de contato do paciente',
54
+ example: '+55 11 99999-9999',
55
+ maxLength: 30,
56
+ })
57
+ @IsString()
58
+ @IsOptional()
59
+ @MaxLength(30)
60
+ phone?: string | null;
61
+
62
+ @ApiPropertyOptional({
63
+ description: 'Gênero do paciente',
64
+ example: 'masculino',
65
+ maxLength: 50,
66
+ })
67
+ @IsString()
68
+ @IsOptional()
69
+ @MaxLength(50)
70
+ gender?: string | null;
71
+
72
+ @ApiPropertyOptional({
73
+ description: 'Endereço completo do paciente',
74
+ example: 'Rua Exemplo, 123 - São Paulo/SP',
75
+ maxLength: 500,
76
+ })
77
+ @IsString()
78
+ @IsOptional()
79
+ @MaxLength(500)
80
+ address?: string | null;
81
+
82
+ @ApiProperty({
83
+ description: 'Indica se o paciente possui alguma deficiência',
84
+ example: true,
85
+ })
86
+ @IsBoolean()
87
+ hasDisability: boolean;
88
+
89
+ @ApiPropertyOptional({
90
+ description:
91
+ 'Descrição da deficiência do paciente (obrigatório quando hasDisability for true)',
92
+ example: 'Deficiência visual',
93
+ maxLength: 500,
94
+ })
95
+ @IsString()
96
+ @IsOptional()
97
+ @MaxLength(500)
98
+ disabilityDescription?: string | null;
99
+
100
+ @ApiPropertyOptional({
101
+ description: 'Observação inicial do paciente (opcional)',
102
+ example: 'Paciente chegou com queixa de dor nas costas',
103
+ maxLength: 2000,
104
+ })
105
+ @IsString()
106
+ @IsOptional()
107
+ @MaxLength(2000)
108
+ initialObservation?: string | null;
109
+
110
+ @ApiPropertyOptional({
111
+ description:
112
+ 'Nova observação do paciente (cria uma entrada de histórico de observações)',
113
+ example: 'Paciente tem alergia a penicilina',
114
+ maxLength: 2000,
115
+ })
116
+ @IsString()
117
+ @IsOptional()
118
+ @MaxLength(2000)
119
+ @Transform(({ value, obj }) => value ?? obj.notes ?? obj.observation)
120
+ observation?: string | null;
121
+ }
122
+
@@ -1,10 +1,10 @@
1
- export * from './create-patient.dto';
2
- export * from './update-patient.dto';
3
- export * from './patient-history-entry.dto';
4
- export * from './list-patients-query.dto';
5
- export * from './list-patients-filters.dto';
6
- export * from './upsert-patient-by-phone.dto';
7
- export * from './patient-status.dto';
8
- export * from './patient-document-response.dto';
9
- export * from './update-patient-document.dto';
10
-
1
+ export * from './create-patient.dto';
2
+ export * from './update-patient.dto';
3
+ export * from './patient-history-entry.dto';
4
+ export * from './list-patients-query.dto';
5
+ export * from './list-patients-filters.dto';
6
+ export * from './upsert-patient-by-phone.dto';
7
+ export * from './patient-status.dto';
8
+ export * from './patient-document-response.dto';
9
+ export * from './update-patient-document.dto';
10
+
@@ -1,15 +1,15 @@
1
- /**
2
- * Re-exports PATIENT_LIST_FILTER_KEYS from the query DTO for backward
3
- * compatibility. The generic ParsedFilterDto from `../filters` is now
4
- * the canonical filter shape used across all services.
5
- */
6
- export {
7
- PATIENT_LIST_FILTER_KEYS,
8
- type PatientListFilterKeyDto,
9
- } from './list-patients-query.dto';
10
-
11
- /**
12
- * @deprecated Use `ParsedFilterDto` from `../filters` instead.
13
- * Kept as an alias for backward compatibility during migration.
14
- */
15
- export type { ParsedFilterDto as PatientListFilterDto } from '../filters/parsed-filter.dto';
1
+ /**
2
+ * Re-exports PATIENT_LIST_FILTER_KEYS from the query DTO for backward
3
+ * compatibility. The generic ParsedFilterDto from `../filters` is now
4
+ * the canonical filter shape used across all services.
5
+ */
6
+ export {
7
+ PATIENT_LIST_FILTER_KEYS,
8
+ type PatientListFilterKeyDto,
9
+ } from './list-patients-query.dto';
10
+
11
+ /**
12
+ * @deprecated Use `ParsedFilterDto` from `../filters` instead.
13
+ * Kept as an alias for backward compatibility during migration.
14
+ */
15
+ export type { ParsedFilterDto as PatientListFilterDto } from '../filters/parsed-filter.dto';
@@ -1,61 +1,61 @@
1
- import { ApiPropertyOptional } from '@nestjs/swagger';
2
- import { IsInt, IsOptional, Max, Min } from 'class-validator';
3
- import type { ParsedFilterDto } from '../filters/parsed-filter.dto';
4
-
5
- /**
6
- * Allowed patient entity columns for filtering (camelCase API keys).
7
- * Microservice uses this whitelist to prevent access to non-existent columns.
8
- */
9
- export const PATIENT_LIST_FILTER_KEYS = [
10
- 'id',
11
- 'status',
12
- 'name',
13
- 'cpf',
14
- 'birthDate',
15
- 'email',
16
- 'phone',
17
- 'gender',
18
- 'address',
19
- 'hasDisability',
20
- 'disabilityDescription',
21
- 'createdAt',
22
- 'updatedAt',
23
- ] as const;
24
- export type PatientListFilterKeyDto = (typeof PATIENT_LIST_FILTER_KEYS)[number];
25
-
26
- export class ListPatientsQueryDto {
27
- @ApiPropertyOptional({
28
- description: 'Número da página (iniciando em 1)',
29
- example: 1,
30
- minimum: 1,
31
- default: 1,
32
- })
33
- @IsOptional()
34
- @IsInt()
35
- @Min(1)
36
- page?: number;
37
-
38
- @ApiPropertyOptional({
39
- description: 'Quantidade de registros por página',
40
- example: 20,
41
- minimum: 1,
42
- maximum: 100,
43
- default: 20,
44
- })
45
- @IsOptional()
46
- @IsInt()
47
- @Min(1)
48
- @Max(100)
49
- limit?: number;
50
-
51
- @ApiPropertyOptional({
52
- description:
53
- 'JSON string with an array of filter objects `{ key, op, value }`. ' +
54
- 'Example: `[{"key":"cpf","op":"==","value":"12211117411"}]`. ' +
55
- 'Ops: ==, !=, >, <, >=, <=, in (value must be array for `in`), like, unlike (string pattern).',
56
- type: String,
57
- example: '[{"key":"cpf","op":"==","value":"12211117411"}]',
58
- })
59
- @IsOptional()
60
- filters?: ParsedFilterDto[];
61
- }
1
+ import { ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { IsInt, IsOptional, Max, Min } from 'class-validator';
3
+ import type { ParsedFilterDto } from '../filters/parsed-filter.dto';
4
+
5
+ /**
6
+ * Allowed patient entity columns for filtering (camelCase API keys).
7
+ * Microservice uses this whitelist to prevent access to non-existent columns.
8
+ */
9
+ export const PATIENT_LIST_FILTER_KEYS = [
10
+ 'id',
11
+ 'status',
12
+ 'name',
13
+ 'cpf',
14
+ 'birthDate',
15
+ 'email',
16
+ 'phone',
17
+ 'gender',
18
+ 'address',
19
+ 'hasDisability',
20
+ 'disabilityDescription',
21
+ 'createdAt',
22
+ 'updatedAt',
23
+ ] as const;
24
+ export type PatientListFilterKeyDto = (typeof PATIENT_LIST_FILTER_KEYS)[number];
25
+
26
+ export class ListPatientsQueryDto {
27
+ @ApiPropertyOptional({
28
+ description: 'Número da página (iniciando em 1)',
29
+ example: 1,
30
+ minimum: 1,
31
+ default: 1,
32
+ })
33
+ @IsOptional()
34
+ @IsInt()
35
+ @Min(1)
36
+ page?: number;
37
+
38
+ @ApiPropertyOptional({
39
+ description: 'Quantidade de registros por página',
40
+ example: 20,
41
+ minimum: 1,
42
+ maximum: 100,
43
+ default: 20,
44
+ })
45
+ @IsOptional()
46
+ @IsInt()
47
+ @Min(1)
48
+ @Max(100)
49
+ limit?: number;
50
+
51
+ @ApiPropertyOptional({
52
+ description:
53
+ 'JSON string with an array of filter objects `{ key, op, value }`. ' +
54
+ 'Example: `[{"key":"cpf","op":"==","value":"12211117411"}]`. ' +
55
+ 'Ops: ==, !=, >, <, >=, <=, in (value must be array for `in`), like, unlike (string pattern).',
56
+ type: String,
57
+ example: '[{"key":"cpf","op":"==","value":"12211117411"}]',
58
+ })
59
+ @IsOptional()
60
+ filters?: ParsedFilterDto[];
61
+ }
@@ -1,33 +1,33 @@
1
- import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
-
3
- export class PatientDocumentResponseDto {
4
- @ApiProperty()
5
- id: string;
6
-
7
- @ApiProperty()
8
- patientId: string;
9
-
10
- @ApiProperty()
11
- storageId: string;
12
-
13
- @ApiProperty()
14
- objectKey: string;
15
-
16
- @ApiProperty()
17
- displayName: string;
18
-
19
- @ApiPropertyOptional()
20
- contentType: string | null;
21
-
22
- @ApiProperty()
23
- sizeBytes: string;
24
-
25
- @ApiPropertyOptional()
26
- createdByUserId: string | null;
27
-
28
- @ApiProperty()
29
- createdAt: string;
30
-
31
- @ApiProperty()
32
- updatedAt: string;
33
- }
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+
3
+ export class PatientDocumentResponseDto {
4
+ @ApiProperty()
5
+ id: string;
6
+
7
+ @ApiProperty()
8
+ patientId: string;
9
+
10
+ @ApiProperty()
11
+ storageId: string;
12
+
13
+ @ApiProperty()
14
+ objectKey: string;
15
+
16
+ @ApiProperty()
17
+ displayName: string;
18
+
19
+ @ApiPropertyOptional()
20
+ contentType: string | null;
21
+
22
+ @ApiProperty()
23
+ sizeBytes: string;
24
+
25
+ @ApiPropertyOptional()
26
+ createdByUserId: string | null;
27
+
28
+ @ApiProperty()
29
+ createdAt: string;
30
+
31
+ @ApiProperty()
32
+ updatedAt: string;
33
+ }
@@ -1,22 +1,22 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
- import { IsDateString, IsNotEmpty, IsString, MaxLength } from 'class-validator';
3
-
4
- export class PatientHistoryEntryDto {
5
- @ApiProperty({
6
- description: 'Data em que a observação foi registrada',
7
- example: '2025-03-10T10:00:00.000Z',
8
- })
9
- @IsDateString()
10
- createdAt: string;
11
-
12
- @ApiProperty({
13
- description: 'Texto da observação sobre o paciente',
14
- example: 'Paciente relatou melhora significativa nos sintomas.',
15
- maxLength: 2000,
16
- })
17
- @IsString()
18
- @IsNotEmpty()
19
- @MaxLength(2000)
20
- note: string;
21
- }
22
-
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { IsDateString, IsNotEmpty, IsString, MaxLength } from 'class-validator';
3
+
4
+ export class PatientHistoryEntryDto {
5
+ @ApiProperty({
6
+ description: 'Data em que a observação foi registrada',
7
+ example: '2025-03-10T10:00:00.000Z',
8
+ })
9
+ @IsDateString()
10
+ createdAt: string;
11
+
12
+ @ApiProperty({
13
+ description: 'Texto da observação sobre o paciente',
14
+ example: 'Paciente relatou melhora significativa nos sintomas.',
15
+ maxLength: 2000,
16
+ })
17
+ @IsString()
18
+ @IsNotEmpty()
19
+ @MaxLength(2000)
20
+ note: string;
21
+ }
22
+