tychat-contracts 1.0.70 → 1.0.71
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/dist/conversations/conversation-response.dto.d.ts +2 -2
- package/dist/conversations/conversation-response.dto.d.ts.map +1 -1
- package/dist/conversations/conversation-response.dto.js +5 -4
- package/dist/conversations/conversation-session-response.dto.d.ts.map +1 -1
- package/dist/conversations/conversation-session-response.dto.js +3 -2
- package/dist/conversations/conversation-type.dto.d.ts +4 -1
- package/dist/conversations/conversation-type.dto.d.ts.map +1 -1
- package/dist/conversations/conversation-type.dto.js +8 -3
- package/dist/conversations/create-conversation-session.dto.d.ts.map +1 -1
- package/dist/conversations/create-conversation-session.dto.js +3 -2
- package/dist/conversations/create-conversation.dto.d.ts +2 -2
- package/dist/conversations/create-conversation.dto.d.ts.map +1 -1
- package/dist/conversations/create-conversation.dto.js +6 -5
- package/dist/patients/index.d.ts +1 -0
- package/dist/patients/index.d.ts.map +1 -1
- package/dist/patients/index.js +1 -0
- package/dist/patients/upsert-patient-by-phone.dto.d.ts +9 -0
- package/dist/patients/upsert-patient-by-phone.dto.d.ts.map +1 -0
- package/dist/patients/upsert-patient-by-phone.dto.js +45 -0
- package/package.json +1 -1
- package/src/conversations/conversation-response.dto.ts +8 -7
- package/src/conversations/conversation-session-response.dto.ts +4 -3
- package/src/conversations/conversation-type.dto.ts +12 -3
- package/src/conversations/create-conversation-session.dto.ts +4 -3
- package/src/conversations/create-conversation.dto.ts +8 -7
- package/src/patients/index.ts +1 -0
- package/src/patients/upsert-patient-by-phone.dto.ts +29 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConversationMessageTypeDto } from './conversation-type.dto';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a persisted conversation message returned by the API.
|
|
4
4
|
*/
|
|
@@ -8,7 +8,7 @@ export declare class ConversationResponseDto {
|
|
|
8
8
|
unitId?: number;
|
|
9
9
|
patientId: string;
|
|
10
10
|
sessionUuid: string;
|
|
11
|
-
type:
|
|
11
|
+
type: ConversationMessageTypeDto;
|
|
12
12
|
message: string;
|
|
13
13
|
aiUsageId?: string;
|
|
14
14
|
createdAt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-response.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"conversation-response.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE;;GAEG;AACH,qBAAa,uBAAuB;IAIlC,EAAE,EAAE,MAAM,CAAC;IAKX,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,CAAC,EAAE,MAAM,CAAC;IAShB,SAAS,EAAE,MAAM,CAAC;IAQlB,WAAW,EAAE,MAAM,CAAC;IAMpB,IAAI,EAAE,0BAA0B,CAAC;IAQjC,OAAO,EAAE,MAAM,CAAC;IAQhB,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -46,11 +46,12 @@ __decorate([
|
|
|
46
46
|
], ConversationResponseDto.prototype, "unitId", void 0);
|
|
47
47
|
__decorate([
|
|
48
48
|
(0, swagger_1.ApiProperty)({
|
|
49
|
-
description: 'Patient
|
|
50
|
-
example: '
|
|
49
|
+
description: 'Patient UUID',
|
|
50
|
+
example: '550e8400-e29b-41d4-a716-446655440000',
|
|
51
51
|
}),
|
|
52
52
|
(0, class_validator_1.IsString)(),
|
|
53
53
|
(0, class_validator_1.IsNotEmpty)(),
|
|
54
|
+
(0, class_validator_1.IsUUID)(),
|
|
54
55
|
__metadata("design:type", String)
|
|
55
56
|
], ConversationResponseDto.prototype, "patientId", void 0);
|
|
56
57
|
__decorate([
|
|
@@ -64,8 +65,8 @@ __decorate([
|
|
|
64
65
|
], ConversationResponseDto.prototype, "sessionUuid", void 0);
|
|
65
66
|
__decorate([
|
|
66
67
|
(0, swagger_1.ApiProperty)({
|
|
67
|
-
description: 'Conversation type: "ia" or "
|
|
68
|
-
example: '
|
|
68
|
+
description: 'Conversation message type: "ia", "human" or "patient"',
|
|
69
|
+
example: 'patient',
|
|
69
70
|
}),
|
|
70
71
|
__metadata("design:type", String)
|
|
71
72
|
], ConversationResponseDto.prototype, "type", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-session-response.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-session-response.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,8BAA8B;IAIzC,EAAE,EAAE,MAAM,CAAC;IAQX,WAAW,EAAE,MAAM,CAAC;IAKpB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation-session-response.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-session-response.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,8BAA8B;IAIzC,EAAE,EAAE,MAAM,CAAC;IAQX,WAAW,EAAE,MAAM,CAAC;IAKpB,MAAM,EAAE,MAAM,CAAC;IASf,SAAS,EAAE,MAAM,CAAC;IAIlB,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,SAAS,EAAE,MAAM,CAAC;IAQlB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -49,11 +49,12 @@ __decorate([
|
|
|
49
49
|
], ConversationSessionResponseDto.prototype, "tenant", void 0);
|
|
50
50
|
__decorate([
|
|
51
51
|
(0, swagger_1.ApiProperty)({
|
|
52
|
-
description: 'Patient
|
|
53
|
-
example: '
|
|
52
|
+
description: 'Patient UUID',
|
|
53
|
+
example: '550e8400-e29b-41d4-a716-446655440000',
|
|
54
54
|
}),
|
|
55
55
|
(0, class_validator_1.IsString)(),
|
|
56
56
|
(0, class_validator_1.IsNotEmpty)(),
|
|
57
|
+
(0, class_validator_1.IsUUID)(),
|
|
57
58
|
__metadata("design:type", String)
|
|
58
59
|
], ConversationSessionResponseDto.prototype, "patientId", void 0);
|
|
59
60
|
__decorate([
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare const CONVERSATION_SESSION_TYPES: readonly ["ia", "human"];
|
|
1
2
|
export declare const CONVERSATION_TYPES: readonly ["ia", "human"];
|
|
2
|
-
export type ConversationTypeDto = (typeof
|
|
3
|
+
export type ConversationTypeDto = (typeof CONVERSATION_SESSION_TYPES)[number];
|
|
4
|
+
export declare const CONVERSATION_MESSAGE_TYPES: readonly ["ia", "human", "patient"];
|
|
5
|
+
export type ConversationMessageTypeDto = (typeof CONVERSATION_MESSAGE_TYPES)[number];
|
|
3
6
|
//# sourceMappingURL=conversation-type.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-type.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-type.dto.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"conversation-type.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-type.dto.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,0BAA2B,CAAC;AAGnE,eAAO,MAAM,kBAAkB,0BAA6B,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAI9E,eAAO,MAAM,0BAA0B,qCAAsC,CAAC;AAC9E,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONVERSATION_TYPES = void 0;
|
|
4
|
-
// Allowed conversation types.
|
|
3
|
+
exports.CONVERSATION_MESSAGE_TYPES = exports.CONVERSATION_TYPES = exports.CONVERSATION_SESSION_TYPES = void 0;
|
|
4
|
+
// Allowed conversation session types.
|
|
5
5
|
// "ia" → patient interacting with the AI.
|
|
6
6
|
// "human" → human staff member responding to the patient.
|
|
7
|
-
exports.
|
|
7
|
+
exports.CONVERSATION_SESSION_TYPES = ['ia', 'human'];
|
|
8
|
+
// Backwards-compatible alias for session types.
|
|
9
|
+
exports.CONVERSATION_TYPES = exports.CONVERSATION_SESSION_TYPES;
|
|
10
|
+
// Allowed conversation message types for the `conversations` table.
|
|
11
|
+
// "patient" → message authored by the patient/user (WhatsApp sender).
|
|
12
|
+
exports.CONVERSATION_MESSAGE_TYPES = ['ia', 'human', 'patient'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-conversation-session.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/create-conversation-session.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,4BAA4B;IAIvC,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"create-conversation-session.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/create-conversation-session.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,4BAA4B;IAIvC,MAAM,EAAE,MAAM,CAAC;IASf,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -30,11 +30,12 @@ __decorate([
|
|
|
30
30
|
], CreateConversationSessionDto.prototype, "tenant", void 0);
|
|
31
31
|
__decorate([
|
|
32
32
|
(0, swagger_1.ApiProperty)({
|
|
33
|
-
description: 'Patient
|
|
34
|
-
example: '
|
|
33
|
+
description: 'Patient UUID',
|
|
34
|
+
example: '550e8400-e29b-41d4-a716-446655440000',
|
|
35
35
|
}),
|
|
36
36
|
(0, class_validator_1.IsString)(),
|
|
37
37
|
(0, class_validator_1.IsNotEmpty)(),
|
|
38
|
+
(0, class_validator_1.IsUUID)(),
|
|
38
39
|
__metadata("design:type", String)
|
|
39
40
|
], CreateConversationSessionDto.prototype, "patientId", void 0);
|
|
40
41
|
__decorate([
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConversationMessageTypeDto } from './conversation-type.dto';
|
|
2
2
|
/**
|
|
3
3
|
* Payload used to persist a single conversation message.
|
|
4
4
|
* AiUsageId must be provided whenever type is "ia" so token costs can be tracked.
|
|
@@ -8,7 +8,7 @@ export declare class CreateConversationDto {
|
|
|
8
8
|
unitId?: number;
|
|
9
9
|
patientId: string;
|
|
10
10
|
sessionUuid: string;
|
|
11
|
-
type:
|
|
11
|
+
type: ConversationMessageTypeDto;
|
|
12
12
|
message: string;
|
|
13
13
|
aiUsageId?: string;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-conversation.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/create-conversation.dto.ts"],"names":[],"mappings":"AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"create-conversation.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/create-conversation.dto.ts"],"names":[],"mappings":"AAUA,OAAO,EAA8B,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEjG;;;GAGG;AACH,qBAAa,qBAAqB;IAIhC,MAAM,EAAE,MAAM,CAAC;IAMf,MAAM,CAAC,EAAE,MAAM,CAAC;IAShB,SAAS,EAAE,MAAM,CAAC;IAOlB,WAAW,EAAE,MAAM,CAAC;IASpB,IAAI,EAAE,0BAA0B,CAAC;IAQjC,OAAO,EAAE,MAAM,CAAC;IAQhB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -42,11 +42,12 @@ __decorate([
|
|
|
42
42
|
], CreateConversationDto.prototype, "unitId", void 0);
|
|
43
43
|
__decorate([
|
|
44
44
|
(0, swagger_1.ApiProperty)({
|
|
45
|
-
description: 'Patient
|
|
45
|
+
description: 'Patient UUID',
|
|
46
46
|
example: '5511999999999',
|
|
47
47
|
}),
|
|
48
48
|
(0, class_validator_1.IsString)(),
|
|
49
49
|
(0, class_validator_1.IsNotEmpty)(),
|
|
50
|
+
(0, class_validator_1.IsUUID)(),
|
|
50
51
|
__metadata("design:type", String)
|
|
51
52
|
], CreateConversationDto.prototype, "patientId", void 0);
|
|
52
53
|
__decorate([
|
|
@@ -59,11 +60,11 @@ __decorate([
|
|
|
59
60
|
], CreateConversationDto.prototype, "sessionUuid", void 0);
|
|
60
61
|
__decorate([
|
|
61
62
|
(0, swagger_1.ApiProperty)({
|
|
62
|
-
description: 'Conversation type: "ia" when the AI responds
|
|
63
|
-
enum: conversation_type_dto_1.
|
|
64
|
-
example: '
|
|
63
|
+
description: 'Conversation message type: "ia" when the AI responds, "human" when staff responds, "patient" when the patient/user sends the message',
|
|
64
|
+
enum: conversation_type_dto_1.CONVERSATION_MESSAGE_TYPES,
|
|
65
|
+
example: 'patient',
|
|
65
66
|
}),
|
|
66
|
-
(0, class_validator_1.IsEnum)(conversation_type_dto_1.
|
|
67
|
+
(0, class_validator_1.IsEnum)(conversation_type_dto_1.CONVERSATION_MESSAGE_TYPES),
|
|
67
68
|
__metadata("design:type", String)
|
|
68
69
|
], CreateConversationDto.prototype, "type", void 0);
|
|
69
70
|
__decorate([
|
package/dist/patients/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/patients/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/patients/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC"}
|
package/dist/patients/index.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./create-patient.dto"), exports);
|
|
|
18
18
|
__exportStar(require("./update-patient.dto"), exports);
|
|
19
19
|
__exportStar(require("./patient-history-entry.dto"), exports);
|
|
20
20
|
__exportStar(require("./list-patients-query.dto"), exports);
|
|
21
|
+
__exportStar(require("./upsert-patient-by-phone.dto"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal patient information used to upsert a patient based on WhatsApp phone.
|
|
3
|
+
* Used for incoming webhook messages where we don't have CPF/birthDate yet.
|
|
4
|
+
*/
|
|
5
|
+
export declare class UpsertPatientByPhoneDto {
|
|
6
|
+
phone: string;
|
|
7
|
+
pushName?: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=upsert-patient-by-phone.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsert-patient-by-phone.dto.d.ts","sourceRoot":"","sources":["../../src/patients/upsert-patient-by-phone.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,uBAAuB;IASlC,KAAK,EAAE,MAAM,CAAC;IAUd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpsertPatientByPhoneDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* Minimal patient information used to upsert a patient based on WhatsApp phone.
|
|
17
|
+
* Used for incoming webhook messages where we don't have CPF/birthDate yet.
|
|
18
|
+
*/
|
|
19
|
+
class UpsertPatientByPhoneDto {
|
|
20
|
+
phone;
|
|
21
|
+
pushName;
|
|
22
|
+
}
|
|
23
|
+
exports.UpsertPatientByPhoneDto = UpsertPatientByPhoneDto;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({
|
|
26
|
+
description: 'Patient phone as received from WhatsApp (local/normalized format)',
|
|
27
|
+
example: '5511999999999',
|
|
28
|
+
maxLength: 30,
|
|
29
|
+
}),
|
|
30
|
+
(0, class_validator_1.IsString)(),
|
|
31
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
32
|
+
(0, class_validator_1.MaxLength)(30),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], UpsertPatientByPhoneDto.prototype, "phone", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
37
|
+
description: 'WhatsApp contact display name (PushName)',
|
|
38
|
+
example: 'Maria Silva',
|
|
39
|
+
maxLength: 255,
|
|
40
|
+
}),
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
(0, class_validator_1.IsString)(),
|
|
43
|
+
(0, class_validator_1.MaxLength)(255),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], UpsertPatientByPhoneDto.prototype, "pushName", void 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
3
|
-
import {
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
|
3
|
+
import { ConversationMessageTypeDto } from './conversation-type.dto';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a persisted conversation message returned by the API.
|
|
@@ -21,11 +21,12 @@ export class ConversationResponseDto {
|
|
|
21
21
|
unitId?: number;
|
|
22
22
|
|
|
23
23
|
@ApiProperty({
|
|
24
|
-
description: 'Patient
|
|
25
|
-
example: '
|
|
24
|
+
description: 'Patient UUID',
|
|
25
|
+
example: '550e8400-e29b-41d4-a716-446655440000',
|
|
26
26
|
})
|
|
27
27
|
@IsString()
|
|
28
28
|
@IsNotEmpty()
|
|
29
|
+
@IsUUID()
|
|
29
30
|
patientId: string;
|
|
30
31
|
|
|
31
32
|
@ApiProperty({
|
|
@@ -37,10 +38,10 @@ export class ConversationResponseDto {
|
|
|
37
38
|
sessionUuid: string;
|
|
38
39
|
|
|
39
40
|
@ApiProperty({
|
|
40
|
-
description: 'Conversation type: "ia" or "
|
|
41
|
-
example: '
|
|
41
|
+
description: 'Conversation message type: "ia", "human" or "patient"',
|
|
42
|
+
example: 'patient',
|
|
42
43
|
})
|
|
43
|
-
type:
|
|
44
|
+
type: ConversationMessageTypeDto;
|
|
44
45
|
|
|
45
46
|
@ApiProperty({
|
|
46
47
|
description: 'Message content',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a conversation session record returned by the API.
|
|
@@ -25,11 +25,12 @@ export class ConversationSessionResponseDto {
|
|
|
25
25
|
tenant: string;
|
|
26
26
|
|
|
27
27
|
@ApiProperty({
|
|
28
|
-
description: 'Patient
|
|
29
|
-
example: '
|
|
28
|
+
description: 'Patient UUID',
|
|
29
|
+
example: '550e8400-e29b-41d4-a716-446655440000',
|
|
30
30
|
})
|
|
31
31
|
@IsString()
|
|
32
32
|
@IsNotEmpty()
|
|
33
|
+
@IsUUID()
|
|
33
34
|
patientId: string;
|
|
34
35
|
|
|
35
36
|
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
// Allowed conversation types.
|
|
1
|
+
// Allowed conversation session types.
|
|
2
2
|
// "ia" → patient interacting with the AI.
|
|
3
3
|
// "human" → human staff member responding to the patient.
|
|
4
|
-
export const
|
|
5
|
-
|
|
4
|
+
export const CONVERSATION_SESSION_TYPES = ['ia', 'human'] as const;
|
|
5
|
+
|
|
6
|
+
// Backwards-compatible alias for session types.
|
|
7
|
+
export const CONVERSATION_TYPES = CONVERSATION_SESSION_TYPES;
|
|
8
|
+
|
|
9
|
+
export type ConversationTypeDto = (typeof CONVERSATION_SESSION_TYPES)[number];
|
|
10
|
+
|
|
11
|
+
// Allowed conversation message types for the `conversations` table.
|
|
12
|
+
// "patient" → message authored by the patient/user (WhatsApp sender).
|
|
13
|
+
export const CONVERSATION_MESSAGE_TYPES = ['ia', 'human', 'patient'] as const;
|
|
14
|
+
export type ConversationMessageTypeDto = (typeof CONVERSATION_MESSAGE_TYPES)[number];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import { IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
2
|
+
import { IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, Min } from 'class-validator';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Payload used to obtain (or create) an active 24-hour conversation session
|
|
@@ -12,11 +12,12 @@ export class CreateConversationSessionDto {
|
|
|
12
12
|
tenant: string;
|
|
13
13
|
|
|
14
14
|
@ApiProperty({
|
|
15
|
-
description: 'Patient
|
|
16
|
-
example: '
|
|
15
|
+
description: 'Patient UUID',
|
|
16
|
+
example: '550e8400-e29b-41d4-a716-446655440000',
|
|
17
17
|
})
|
|
18
18
|
@IsString()
|
|
19
19
|
@IsNotEmpty()
|
|
20
|
+
@IsUUID()
|
|
20
21
|
patientId: string;
|
|
21
22
|
|
|
22
23
|
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
IsUUID,
|
|
9
9
|
Min,
|
|
10
10
|
} from 'class-validator';
|
|
11
|
-
import {
|
|
11
|
+
import { CONVERSATION_MESSAGE_TYPES, ConversationMessageTypeDto } from './conversation-type.dto';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Payload used to persist a single conversation message.
|
|
@@ -27,11 +27,12 @@ export class CreateConversationDto {
|
|
|
27
27
|
unitId?: number;
|
|
28
28
|
|
|
29
29
|
@ApiProperty({
|
|
30
|
-
description: 'Patient
|
|
30
|
+
description: 'Patient UUID',
|
|
31
31
|
example: '5511999999999',
|
|
32
32
|
})
|
|
33
33
|
@IsString()
|
|
34
34
|
@IsNotEmpty()
|
|
35
|
+
@IsUUID()
|
|
35
36
|
patientId: string;
|
|
36
37
|
|
|
37
38
|
@ApiProperty({
|
|
@@ -43,12 +44,12 @@ export class CreateConversationDto {
|
|
|
43
44
|
|
|
44
45
|
@ApiProperty({
|
|
45
46
|
description:
|
|
46
|
-
'Conversation type: "ia" when the AI responds
|
|
47
|
-
enum:
|
|
48
|
-
example: '
|
|
47
|
+
'Conversation message type: "ia" when the AI responds, "human" when staff responds, "patient" when the patient/user sends the message',
|
|
48
|
+
enum: CONVERSATION_MESSAGE_TYPES,
|
|
49
|
+
example: 'patient',
|
|
49
50
|
})
|
|
50
|
-
@IsEnum(
|
|
51
|
-
type:
|
|
51
|
+
@IsEnum(CONVERSATION_MESSAGE_TYPES)
|
|
52
|
+
type: ConversationMessageTypeDto;
|
|
52
53
|
|
|
53
54
|
@ApiProperty({
|
|
54
55
|
description: 'Message content',
|
package/src/patients/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal patient information used to upsert a patient based on WhatsApp phone.
|
|
6
|
+
* Used for incoming webhook messages where we don't have CPF/birthDate yet.
|
|
7
|
+
*/
|
|
8
|
+
export class UpsertPatientByPhoneDto {
|
|
9
|
+
@ApiProperty({
|
|
10
|
+
description: 'Patient phone as received from WhatsApp (local/normalized format)',
|
|
11
|
+
example: '5511999999999',
|
|
12
|
+
maxLength: 30,
|
|
13
|
+
})
|
|
14
|
+
@IsString()
|
|
15
|
+
@IsNotEmpty()
|
|
16
|
+
@MaxLength(30)
|
|
17
|
+
phone: string;
|
|
18
|
+
|
|
19
|
+
@ApiPropertyOptional({
|
|
20
|
+
description: 'WhatsApp contact display name (PushName)',
|
|
21
|
+
example: 'Maria Silva',
|
|
22
|
+
maxLength: 255,
|
|
23
|
+
})
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@IsString()
|
|
26
|
+
@MaxLength(255)
|
|
27
|
+
pushName?: string;
|
|
28
|
+
}
|
|
29
|
+
|