Application Constants (constants.ts)
Relevant source files
The following files were used as context for generating this wiki page:The constants.ts file is a central repository for static data used throughout the AI for Thai EMS web application. Its primary purpose is to decouple content from the component logic, making the application easier to manage, update, and maintain. It exports several arrays and objects containing information about the project's objectives, research team, timeline, and expected impacts. This data is then imported and rendered by various React components, primarily within App.tsx.
This approach ensures that all display text and project-related data are defined in a single, predictable location. Other files, such as components/AiDemo.tsx and services/geminiService.ts, also define their own local constants for specific functionalities like the AI simulation and API interactions.
Core Data Structures
The constants defined in constants.ts rely on custom types declared in types.ts to ensure data consistency and type safety across the application.
Sources: [constants.ts:1](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/constants.ts#L1), [types.ts](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/types.ts)
Type Definitions
The following diagram illustrates the primary data types used for the constants.
This diagram shows the structure of the Researcher, TimelineEvent, and AiAnalysisResult interfaces defined in types.ts.
Sources: [types.ts:1-22](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/types.ts#L1-L22)
Project Information Constants
These constants hold the core informational content displayed on the main application page. They are all defined in constants.ts and consumed by App.tsx.
Sources: [constants.ts](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/constants.ts), [App.tsx](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/App.tsx)
projectObjectives
This is an array of objects, where each object represents a key objective of the project.
| Title | Description |
|---|---|
| พัฒนาระบบ AI | เพื่อช่วยในการประเมินและรับแจ้งเหตุฉุกเฉินได้อย่างรวดเร็วและมีประสิทธิภาพ |
| ปรับปรุงกระบวนการข้อมูล | เพื่อรวบรวมและจัดการข้อมูลการดำเนินงานสำหรับการเบิกจ่ายค่าบริการให้ถูกต้องและรวดเร็วยิ่งขึ้น |
| สร้างกรอบการกำกับดูแล | เพื่อการใช้ AI ใน EMS ที่สอดคล้องกับแนวทางธรรมาภิบาลของ สพธอ. |
| ลดข้อผิดพลาด | เพื่อลดข้อผิดพลาดในการจัดการข้อมูลและเพิ่มประสิทธิภาพการทำงานของระบบ EMS |
Sources: [constants.ts:3-20](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/constants.ts#L3-L20)
The App.tsx component iterates over this array to render a list of objectives using the Card component.
Sources: [App.tsx:8, 41-45](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/App.tsx#L8)
researchTeam
An array of Researcher objects, listing all individuals involved in the research project.
| Name | Organization | Role |
|---|---|---|
| ดร.ศักดิ์ เสกขุนทด | สพรอ. | ที่ปรึกษา |
| ผศ.นพ.ศรัทธา ริยาพันธ์ | ศิริราช | ที่ปรึกษา |
| ดร.ณัฐนันท์ ทัตพิทักษ์กุล | สวทช. | ที่ปรึกษา |
| ว่าที่สิบโท เอก โอฐน้อย | สพฉ. | หัวหน้าโครงการ |
| นายภาคภูมิ ท่านัดที | สพฉ. | ผู้วิจัย |
| ... (and 7 more) | ... | ... |
Sources: [constants.ts:22-39](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/constants.ts#L22-L39)
This array is mapped in App.tsx to display each team member's name, organization, and role within a grid layout.
Sources: [App.tsx:8, 52-59](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/App.tsx#L8)
timelineEvents
An array of TimelineEvent objects that define the key activities and their completion percentages for the project's timeline.
| Title | Description | Percentage |
|---|---|---|
| กิจกรรมที่ 1: การศึกษาและวิเคราะห์สถานการณ์ปัจจุบัน (Situation Analysis) | รวบรวมข้อมูล, สัมภาษณ์ผู้มีส่วนได้ส่วนเสีย, และวิเคราะห์ปัญหาและความต้องการ | 30 |
| กิจกรรมที่ 2: การพัฒนา Framework และ Roadmap | วิเคราะห์ความพร้อม, จัดทำกรอบแนวทาง, และสร้าง Roadmap การนำ AI มาประยุกต์ใช้ | 50 |
| กิจกรรมที่ 3: การเผยแพร่กรอบแนวทาง | เผยแพร่ Framework และ Roadmap ที่พัฒนาขึ้นสู่สาธารณะและหน่วยงานที่เกี่ยวข้อง | 20 |
Sources: [constants.ts:41-57](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/constants.ts#L41-L57)
The App.tsx component passes this data to the Timeline component, which is responsible for rendering the visual timeline.
Sources: [App.tsx:8, 61-63](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/App.tsx#L8), [components/Timeline.tsx:8-10](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/components/Timeline.tsx#L8-L10)
expectedImpacts
An object containing arrays of strings that categorize the project's expected benefits for the government, private sector, and the community.
-
government:
- "สามารถนำข้อมูลจากระบบ AI ไปใช้วางแผนและบริหารจัดการ EMS ให้มีประสิทธิภาพมากขึ้น"
- ...and 2 more items.
-
private:
- "บริษัทเทคโนโลยีสามารถนำเทคโนโลยี AI ไปพัฒนาและขยายขีดความสามารถของซอฟต์แวร์"
- ...and 1 more item.
-
community:
- "ประชาชนเข้าถึงบริการ EMS ที่รวดเร็วและมีคุณภาพสูงขึ้น เพิ่มโอกาสรอดชีวิต"
- ...and 2 more items.
-
Sources: [constants.ts:59-78](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/constants.ts#L59-L78)
This data is used in App.tsx to populate three distinct sections detailing the impacts for each group.
Sources: [App.tsx:8, 68-91](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/App.tsx#L8)
Component-Specific Constants
Some components define their own constants for managing internal state or simulations.
AiDemo Constants
The AiDemo.tsx component uses local constants to drive its simulation of an AI-assisted emergency dispatch call.
initialAnalysis: An object of typeAiAnalysisResultthat serves as the starting state for the AI analysis dashboard. All its fields are initialized tonullor empty strings.fullTranscript: An array of objects representing the complete, hardcoded conversation between a dispatcher and a caller. This array drives the step-by-step simulation.
// components/AiDemo.tsx:5-11
const initialAnalysis: AiAnalysisResult = {
incidentType: null,
location: null,
severity: null,
recommendedAction: null,
extractedData: { name: '', age: '', condition: '' },
};
// components/AiDemo.tsx:13-21
const fullTranscript = [
{ speaker: 'Dispatcher', text: 'ศูนย์สั่งการเอราวัณ สวัสดีครับ มีอะไรให้ช่วยครับ' },
{ speaker: 'Caller', text: 'ช่วยด้วยครับ! พ่อผมหายใจไม่ออก แน่นหน้าอกมากครับ' },
// ... more transcript lines
];
Sources: [components/AiDemo.tsx:5-21](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/components/AiDemo.tsx#L5-L21)
geminiService Schema Constant
The analyzeEmergencyCallWithGemini function in services/geminiService.ts defines a schema constant. This constant is crucial for interacting with the Gemini API, as it instructs the model to return its analysis in a specific, structured JSON format that matches the AiAnalysisResult type.
The following diagram shows the structure of the JSON schema.
This schema ensures that the API response is predictable and can be safely parsed into the AiAnalysisResult type.
Sources: [services/geminiService.ts:8-30](https://github.com/ppakpoomm/AI-for-Thai-EMS/blob/HEAD/services/geminiService.ts#L8-L30)
Conclusion
The application's constants, primarily centralized in constants.ts, are fundamental to the project's architecture. They provide a single source of truth for static content, which promotes code clarity, simplifies updates, and separates data from presentation logic. This design pattern is consistently applied for project-wide information, while more localized constants are used within specific components (AiDemo.tsx) and services (geminiService.ts) to manage their unique requirements.