@blackcode_sa/metaestetics-api 1.12.29 → 1.12.31

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/index.d.mts CHANGED
@@ -3234,6 +3234,47 @@ interface UpdateMedicationData extends Partial<AddMedicationData> {
3234
3234
  }
3235
3235
  declare const DEFAULT_MEDICAL_INFO: Omit<PatientMedicalInfo, "patientId" | "lastUpdated" | "updatedBy">;
3236
3236
 
3237
+ declare const AESTHETIC_ANALYSIS_COLLECTION = "aesthetic-analysis";
3238
+ interface ClinicalFinding {
3239
+ concernCategory: string;
3240
+ concernName: string;
3241
+ severityLevel?: string;
3242
+ impactLevel?: string;
3243
+ clinicalNotes?: string;
3244
+ }
3245
+ interface AssessmentScale {
3246
+ scaleName: string;
3247
+ scaleValue: string;
3248
+ category: string;
3249
+ }
3250
+ interface PatientGoals {
3251
+ treatmentTimeline?: string;
3252
+ budgetRange?: string;
3253
+ naturalnessPreference: number;
3254
+ selectedGoalTemplate?: string;
3255
+ priorities: string[];
3256
+ }
3257
+ interface AestheticAnalysis {
3258
+ patientId: string;
3259
+ lastUpdatedBy: string;
3260
+ lastUpdatedByRole: 'PATIENT' | 'PRACTITIONER';
3261
+ patientGoals: PatientGoals;
3262
+ clinicalFindings: ClinicalFinding[];
3263
+ assessmentScales: AssessmentScale[];
3264
+ createdAt?: Timestamp | any;
3265
+ updatedAt?: Timestamp | any;
3266
+ }
3267
+ interface CreateAestheticAnalysisData {
3268
+ patientGoals: PatientGoals;
3269
+ clinicalFindings: ClinicalFinding[];
3270
+ assessmentScales: AssessmentScale[];
3271
+ }
3272
+ interface UpdateAestheticAnalysisData {
3273
+ patientGoals?: PatientGoals;
3274
+ clinicalFindings?: ClinicalFinding[];
3275
+ assessmentScales?: AssessmentScale[];
3276
+ }
3277
+
3237
3278
  declare const PATIENTS_COLLECTION = "patients";
3238
3279
  declare const PATIENT_SENSITIVE_INFO_COLLECTION = "sensitive-info";
3239
3280
  declare const PATIENT_MEDICAL_HISTORY_COLLECTION = "medical-history";
@@ -5237,7 +5278,7 @@ declare class ClinicService extends BaseService {
5237
5278
  private functions;
5238
5279
  constructor(db: Firestore, auth: Auth, app: FirebaseApp, clinicGroupService: ClinicGroupService, clinicAdminService: ClinicAdminService, mediaService: MediaService);
5239
5280
  /**
5240
- * Get timezone from coordinates using geo-tz library
5281
+ * Get timezone from coordinates using tz-lookup library
5241
5282
  * @param lat Latitude
5242
5283
  * @param lng Longitude
5243
5284
  * @returns IANA timezone string
@@ -6969,4 +7010,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
6969
7010
  declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
6970
7011
  declare const getFirebaseFunctions: () => Promise<Functions>;
6971
7012
 
6972
- export { APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
7013
+ export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScale, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFinding, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
package/dist/index.d.ts CHANGED
@@ -3234,6 +3234,47 @@ interface UpdateMedicationData extends Partial<AddMedicationData> {
3234
3234
  }
3235
3235
  declare const DEFAULT_MEDICAL_INFO: Omit<PatientMedicalInfo, "patientId" | "lastUpdated" | "updatedBy">;
3236
3236
 
3237
+ declare const AESTHETIC_ANALYSIS_COLLECTION = "aesthetic-analysis";
3238
+ interface ClinicalFinding {
3239
+ concernCategory: string;
3240
+ concernName: string;
3241
+ severityLevel?: string;
3242
+ impactLevel?: string;
3243
+ clinicalNotes?: string;
3244
+ }
3245
+ interface AssessmentScale {
3246
+ scaleName: string;
3247
+ scaleValue: string;
3248
+ category: string;
3249
+ }
3250
+ interface PatientGoals {
3251
+ treatmentTimeline?: string;
3252
+ budgetRange?: string;
3253
+ naturalnessPreference: number;
3254
+ selectedGoalTemplate?: string;
3255
+ priorities: string[];
3256
+ }
3257
+ interface AestheticAnalysis {
3258
+ patientId: string;
3259
+ lastUpdatedBy: string;
3260
+ lastUpdatedByRole: 'PATIENT' | 'PRACTITIONER';
3261
+ patientGoals: PatientGoals;
3262
+ clinicalFindings: ClinicalFinding[];
3263
+ assessmentScales: AssessmentScale[];
3264
+ createdAt?: Timestamp | any;
3265
+ updatedAt?: Timestamp | any;
3266
+ }
3267
+ interface CreateAestheticAnalysisData {
3268
+ patientGoals: PatientGoals;
3269
+ clinicalFindings: ClinicalFinding[];
3270
+ assessmentScales: AssessmentScale[];
3271
+ }
3272
+ interface UpdateAestheticAnalysisData {
3273
+ patientGoals?: PatientGoals;
3274
+ clinicalFindings?: ClinicalFinding[];
3275
+ assessmentScales?: AssessmentScale[];
3276
+ }
3277
+
3237
3278
  declare const PATIENTS_COLLECTION = "patients";
3238
3279
  declare const PATIENT_SENSITIVE_INFO_COLLECTION = "sensitive-info";
3239
3280
  declare const PATIENT_MEDICAL_HISTORY_COLLECTION = "medical-history";
@@ -5237,7 +5278,7 @@ declare class ClinicService extends BaseService {
5237
5278
  private functions;
5238
5279
  constructor(db: Firestore, auth: Auth, app: FirebaseApp, clinicGroupService: ClinicGroupService, clinicAdminService: ClinicAdminService, mediaService: MediaService);
5239
5280
  /**
5240
- * Get timezone from coordinates using geo-tz library
5281
+ * Get timezone from coordinates using tz-lookup library
5241
5282
  * @param lat Latitude
5242
5283
  * @param lng Longitude
5243
5284
  * @returns IANA timezone string
@@ -6969,4 +7010,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
6969
7010
  declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
6970
7011
  declare const getFirebaseFunctions: () => Promise<Functions>;
6971
7012
 
6972
- export { APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
7013
+ export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScale, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFinding, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AESTHETIC_ANALYSIS_COLLECTION: () => AESTHETIC_ANALYSIS_COLLECTION,
33
34
  APPOINTMENTS_COLLECTION: () => APPOINTMENTS_COLLECTION,
34
35
  AdminTokenStatus: () => AdminTokenStatus,
35
36
  AllergyType: () => AllergyType,
@@ -1248,6 +1249,9 @@ var DEFAULT_MEDICAL_INFO = {
1248
1249
  currentMedications: []
1249
1250
  };
1250
1251
 
1252
+ // src/types/patient/aesthetic-analysis.types.ts
1253
+ var AESTHETIC_ANALYSIS_COLLECTION = "aesthetic-analysis";
1254
+
1251
1255
  // src/types/patient/index.ts
1252
1256
  var PATIENTS_COLLECTION = "patients";
1253
1257
  var PATIENT_SENSITIVE_INFO_COLLECTION = "sensitive-info";
@@ -8577,7 +8581,7 @@ var ClinicGroupService = class extends BaseService {
8577
8581
  // src/services/clinic/clinic.service.ts
8578
8582
  var import_firestore28 = require("firebase/firestore");
8579
8583
  var import_functions2 = require("firebase/functions");
8580
- var import_geo_tz = require("geo-tz");
8584
+ var import_tz_lookup = __toESM(require("tz-lookup"));
8581
8585
  var import_geofire_common7 = require("geofire-common");
8582
8586
  var import_zod20 = require("zod");
8583
8587
 
@@ -9333,18 +9337,15 @@ var ClinicService = class extends BaseService {
9333
9337
  this.functions = (0, import_functions2.getFunctions)(app, "europe-west6");
9334
9338
  }
9335
9339
  /**
9336
- * Get timezone from coordinates using geo-tz library
9340
+ * Get timezone from coordinates using tz-lookup library
9337
9341
  * @param lat Latitude
9338
9342
  * @param lng Longitude
9339
9343
  * @returns IANA timezone string
9340
9344
  */
9341
9345
  getTimezone(lat, lng) {
9342
9346
  try {
9343
- const timezones = (0, import_geo_tz.find)(lat, lng);
9344
- if (timezones && timezones.length > 0) {
9345
- return timezones[0];
9346
- }
9347
- return null;
9347
+ const timezone = (0, import_tz_lookup.default)(lat, lng);
9348
+ return timezone || null;
9348
9349
  } catch (error) {
9349
9350
  console.error("[CLINIC_SERVICE] Error getting timezone:", error);
9350
9351
  return null;
@@ -18280,6 +18281,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
18280
18281
  })(RequirementType || {});
18281
18282
  // Annotate the CommonJS export names for ESM import in node:
18282
18283
  0 && (module.exports = {
18284
+ AESTHETIC_ANALYSIS_COLLECTION,
18283
18285
  APPOINTMENTS_COLLECTION,
18284
18286
  AdminTokenStatus,
18285
18287
  AllergyType,
package/dist/index.mjs CHANGED
@@ -1148,6 +1148,9 @@ var DEFAULT_MEDICAL_INFO = {
1148
1148
  currentMedications: []
1149
1149
  };
1150
1150
 
1151
+ // src/types/patient/aesthetic-analysis.types.ts
1152
+ var AESTHETIC_ANALYSIS_COLLECTION = "aesthetic-analysis";
1153
+
1151
1154
  // src/types/patient/index.ts
1152
1155
  var PATIENTS_COLLECTION = "patients";
1153
1156
  var PATIENT_SENSITIVE_INFO_COLLECTION = "sensitive-info";
@@ -8646,7 +8649,7 @@ import {
8646
8649
  arrayUnion as arrayUnion7
8647
8650
  } from "firebase/firestore";
8648
8651
  import { getFunctions as getFunctions2 } from "firebase/functions";
8649
- import { find as findTimezone } from "geo-tz";
8652
+ import tzlookup from "tz-lookup";
8650
8653
  import {
8651
8654
  geohashForLocation as geohashForLocation4
8652
8655
  } from "geofire-common";
@@ -9433,18 +9436,15 @@ var ClinicService = class extends BaseService {
9433
9436
  this.functions = getFunctions2(app, "europe-west6");
9434
9437
  }
9435
9438
  /**
9436
- * Get timezone from coordinates using geo-tz library
9439
+ * Get timezone from coordinates using tz-lookup library
9437
9440
  * @param lat Latitude
9438
9441
  * @param lng Longitude
9439
9442
  * @returns IANA timezone string
9440
9443
  */
9441
9444
  getTimezone(lat, lng) {
9442
9445
  try {
9443
- const timezones = findTimezone(lat, lng);
9444
- if (timezones && timezones.length > 0) {
9445
- return timezones[0];
9446
- }
9447
- return null;
9446
+ const timezone = tzlookup(lat, lng);
9447
+ return timezone || null;
9448
9448
  } catch (error) {
9449
9449
  console.error("[CLINIC_SERVICE] Error getting timezone:", error);
9450
9450
  return null;
@@ -18615,6 +18615,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
18615
18615
  return RequirementType2;
18616
18616
  })(RequirementType || {});
18617
18617
  export {
18618
+ AESTHETIC_ANALYSIS_COLLECTION,
18618
18619
  APPOINTMENTS_COLLECTION,
18619
18620
  AdminTokenStatus,
18620
18621
  AllergyType,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.12.29",
4
+ "version": "1.12.31",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -98,9 +98,9 @@
98
98
  "axios": "^1.8.3",
99
99
  "expo-server-sdk": "^3.13.0",
100
100
  "firebase-admin": "^13.0.2",
101
- "geo-tz": "^8.1.4",
102
101
  "geofire-common": "^6.0.0",
103
102
  "luxon": "^3.7.1",
103
+ "tz-lookup": "^6.1.25",
104
104
  "zod": "^3.24.1"
105
105
  },
106
106
  "optionalDependencies": {
@@ -18,7 +18,7 @@ import {
18
18
  arrayRemove,
19
19
  } from "firebase/firestore";
20
20
  import { getFunctions, httpsCallable } from "firebase/functions";
21
- import { find as findTimezone } from "geo-tz";
21
+ import tzlookup from "tz-lookup";
22
22
  import { BaseService } from "../base.service";
23
23
  import {
24
24
  Clinic,
@@ -83,18 +83,15 @@ export class ClinicService extends BaseService {
83
83
  }
84
84
 
85
85
  /**
86
- * Get timezone from coordinates using geo-tz library
86
+ * Get timezone from coordinates using tz-lookup library
87
87
  * @param lat Latitude
88
88
  * @param lng Longitude
89
89
  * @returns IANA timezone string
90
90
  */
91
91
  private getTimezone(lat: number, lng: number): string | null {
92
92
  try {
93
- const timezones = findTimezone(lat, lng);
94
- if (timezones && timezones.length > 0) {
95
- return timezones[0];
96
- }
97
- return null;
93
+ const timezone = tzlookup(lat, lng);
94
+ return timezone || null;
98
95
  } catch (error) {
99
96
  console.error("[CLINIC_SERVICE] Error getting timezone:", error);
100
97
  return null;
@@ -0,0 +1,121 @@
1
+ import { getDoc, updateDoc, setDoc, serverTimestamp, Firestore, doc } from 'firebase/firestore';
2
+ import {
3
+ AestheticAnalysis,
4
+ CreateAestheticAnalysisData,
5
+ UpdateAestheticAnalysisData,
6
+ AESTHETIC_ANALYSIS_COLLECTION,
7
+ PATIENTS_COLLECTION,
8
+ } from '../../../types/patient';
9
+ import { UserRole } from '../../../types';
10
+ import {
11
+ createAestheticAnalysisSchema,
12
+ updateAestheticAnalysisSchema,
13
+ aestheticAnalysisSchema,
14
+ } from '../../../validations/patient/aesthetic-analysis.schema';
15
+ import { getPatientDocRef } from './docs.utils';
16
+ import { AuthError } from '../../../errors/auth.errors';
17
+ import { getPractitionerProfileByUserRef } from './practitioner.utils';
18
+ import { getClinicAdminByUserRef } from '../../clinic/utils/admin.utils';
19
+
20
+ export const getAestheticAnalysisDocRef = (db: Firestore, patientId: string) => {
21
+ return doc(db, PATIENTS_COLLECTION, patientId, AESTHETIC_ANALYSIS_COLLECTION, patientId);
22
+ };
23
+
24
+ const checkAestheticAnalysisAccessUtil = async (
25
+ db: Firestore,
26
+ patientId: string,
27
+ requesterId: string,
28
+ requesterRoles: UserRole[]
29
+ ): Promise<void> => {
30
+ const patientDoc = await getDoc(getPatientDocRef(db, patientId));
31
+ if (!patientDoc.exists()) {
32
+ throw new Error('Patient profile not found');
33
+ }
34
+ const patientData = patientDoc.data() as any;
35
+
36
+ if (patientData.userRef && patientData.userRef === requesterId) {
37
+ return;
38
+ }
39
+
40
+ if (requesterRoles.includes(UserRole.PRACTITIONER)) {
41
+ const practitionerProfile = await getPractitionerProfileByUserRef(db, requesterId);
42
+ if (practitionerProfile && patientData.doctorIds?.includes(practitionerProfile.id)) {
43
+ return;
44
+ }
45
+ }
46
+
47
+ if (requesterRoles.includes(UserRole.CLINIC_ADMIN)) {
48
+ const adminProfile = await getClinicAdminByUserRef(db, requesterId);
49
+ if (adminProfile && adminProfile.clinicsManaged) {
50
+ const hasAccess = adminProfile.clinicsManaged.some((managedClinicId) =>
51
+ patientData.clinicIds?.includes(managedClinicId)
52
+ );
53
+ if (hasAccess) {
54
+ return;
55
+ }
56
+ }
57
+ }
58
+
59
+ throw new AuthError(
60
+ 'Unauthorized access to aesthetic analysis.',
61
+ 'AUTH/UNAUTHORIZED_ACCESS',
62
+ 403
63
+ );
64
+ };
65
+
66
+ export const getAestheticAnalysisUtil = async (
67
+ db: Firestore,
68
+ patientId: string,
69
+ requesterId: string,
70
+ requesterRoles: UserRole[]
71
+ ): Promise<AestheticAnalysis | null> => {
72
+ await checkAestheticAnalysisAccessUtil(db, patientId, requesterId, requesterRoles);
73
+
74
+ const docRef = getAestheticAnalysisDocRef(db, patientId);
75
+ const snapshot = await getDoc(docRef);
76
+
77
+ if (!snapshot.exists()) {
78
+ return null;
79
+ }
80
+
81
+ return aestheticAnalysisSchema.parse(snapshot.data());
82
+ };
83
+
84
+ export const createOrUpdateAestheticAnalysisUtil = async (
85
+ db: Firestore,
86
+ patientId: string,
87
+ data: CreateAestheticAnalysisData | UpdateAestheticAnalysisData,
88
+ requesterId: string,
89
+ requesterRoles: UserRole[],
90
+ isUpdate: boolean = false
91
+ ): Promise<void> => {
92
+ await checkAestheticAnalysisAccessUtil(db, patientId, requesterId, requesterRoles);
93
+
94
+ const validatedData = isUpdate
95
+ ? updateAestheticAnalysisSchema.parse(data)
96
+ : createAestheticAnalysisSchema.parse(data);
97
+
98
+ const docRef = getAestheticAnalysisDocRef(db, patientId);
99
+ const snapshot = await getDoc(docRef);
100
+
101
+ const requesterRole = requesterRoles.includes(UserRole.PRACTITIONER) ? 'PRACTITIONER' : 'PATIENT';
102
+
103
+ if (!snapshot.exists()) {
104
+ await setDoc(docRef, {
105
+ patientId,
106
+ ...validatedData,
107
+ lastUpdatedBy: requesterId,
108
+ lastUpdatedByRole: requesterRole,
109
+ createdAt: serverTimestamp(),
110
+ updatedAt: serverTimestamp(),
111
+ });
112
+ } else {
113
+ await updateDoc(docRef, {
114
+ ...validatedData,
115
+ lastUpdatedBy: requesterId,
116
+ lastUpdatedByRole: requesterRole,
117
+ updatedAt: serverTimestamp(),
118
+ });
119
+ }
120
+ };
121
+
@@ -76,8 +76,8 @@ export interface ProcedureExtendedInfo {
76
76
  procedureTechnologyName: string;
77
77
  procedureProductBrandId: string;
78
78
  procedureProductBrandName: string;
79
- procedureProductId: string;
80
- procedureProductName: string;
79
+ procedureProductId: string; // We need to have more than one product allowed in this data, this is coming from aggregation, so please update aggregation and this data type
80
+ procedureProductName: string; // We need to have more than one product allowed in this data, this is coming from aggregation, so please update aggregation and this data type
81
81
  }
82
82
 
83
83
  /**
@@ -134,7 +134,7 @@ export interface ZonePhotoUploadData {
134
134
  /**
135
135
  * Interface for billing information per zone
136
136
  */
137
- export interface BillingPerZone {
137
+ export interface BillingPerZone { // We should rename this to ZoneItemData and we should expend it as per our documentations (will be used for both zone items in step 3 and summary and pricing in the step 4)
138
138
  /** Product name/description */
139
139
  Product: string;
140
140
  /** Product ID */
@@ -168,11 +168,11 @@ export interface FinalBilling {
168
168
  /** Final price including tax */
169
169
  finalPrice: number;
170
170
  /** Total final quantity across all zones */
171
- finalQuantity: number;
171
+ finalQuantity: number; // Not sure we should keep this as well, we keep track of this per item
172
172
  /** Currency for the final billing */
173
173
  currency: Currency;
174
174
  /** Unit of measurement for the final billing */
175
- unitOfMeasurement: PricingMeasure;
175
+ unitOfMeasurement: PricingMeasure; // NO need to keep this, we keep track of this per item
176
176
  }
177
177
 
178
178
  /**
@@ -180,15 +180,16 @@ export interface FinalBilling {
180
180
  */
181
181
  export interface AppointmentMetadata {
182
182
  /** Array of selected zones for the appointment */
183
- selectedZones: string[] | null;
183
+ selectedZones: string[] | null; // We are not going to accept any structure (category.zone.subzone), here we will only accept zone (category.zone), nothing more, nothing less
184
184
  /** Map of zone photos with before/after images and notes */
185
- zonePhotos: Record<string, BeforeAfterPerZone> | null;
185
+ zonePhotos: Record<string, BeforeAfterPerZone> | null; // head.forhead: {object}, head: {object}, but it can't have head.forhead.forhedLeft: {object}
186
186
  /** Map of billing information per zone */
187
- zoneBilling: Record<string, BillingPerZone> | null;
187
+ zoneBilling: Record<string, BillingPerZone> | null; // This is going to change, name it zonesData, and expand this to accept more than one item per key (which is basically zone like category.zone)
188
188
  /** Final billing calculations for the appointment */
189
189
  finalbilling: FinalBilling | null;
190
190
  /** Final note for the appointment */
191
191
  finalizationNotes: string | null;
192
+ // TO-DO: We need to add extended procedures info (when we add multiple procedures, different than default one defined above)
192
193
  }
193
194
 
194
195
  /**
@@ -0,0 +1,52 @@
1
+ import { Timestamp } from 'firebase/firestore';
2
+
3
+ export const AESTHETIC_ANALYSIS_COLLECTION = 'aesthetic-analysis';
4
+
5
+ export interface ClinicalFinding {
6
+ concernCategory: string;
7
+ concernName: string;
8
+ severityLevel?: string;
9
+ impactLevel?: string;
10
+ clinicalNotes?: string;
11
+ }
12
+
13
+ export interface AssessmentScale {
14
+ scaleName: string;
15
+ scaleValue: string;
16
+ category: string;
17
+ }
18
+
19
+ export interface PatientGoals {
20
+ treatmentTimeline?: string;
21
+ budgetRange?: string;
22
+ naturalnessPreference: number;
23
+ selectedGoalTemplate?: string;
24
+ priorities: string[];
25
+ }
26
+
27
+ export interface AestheticAnalysis {
28
+ patientId: string;
29
+
30
+ lastUpdatedBy: string;
31
+ lastUpdatedByRole: 'PATIENT' | 'PRACTITIONER';
32
+
33
+ patientGoals: PatientGoals;
34
+ clinicalFindings: ClinicalFinding[];
35
+ assessmentScales: AssessmentScale[];
36
+
37
+ createdAt?: Timestamp | any;
38
+ updatedAt?: Timestamp | any;
39
+ }
40
+
41
+ export interface CreateAestheticAnalysisData {
42
+ patientGoals: PatientGoals;
43
+ clinicalFindings: ClinicalFinding[];
44
+ assessmentScales: AssessmentScale[];
45
+ }
46
+
47
+ export interface UpdateAestheticAnalysisData {
48
+ patientGoals?: PatientGoals;
49
+ clinicalFindings?: ClinicalFinding[];
50
+ assessmentScales?: AssessmentScale[];
51
+ }
52
+
@@ -256,6 +256,7 @@ export interface RequesterInfo {
256
256
  }
257
257
 
258
258
  export * from "./medical-info.types";
259
+ export * from "./aesthetic-analysis.types";
259
260
 
260
261
  // This is a type that combines all the patient data - used only in UI Frontend App
261
262
  export interface PatientProfileComplete {
@@ -0,0 +1,4 @@
1
+ declare module 'tz-lookup' {
2
+ function tzlookup(lat: number, lng: number): string;
3
+ export default tzlookup;
4
+ }
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+
3
+ export const clinicalFindingSchema = z.object({
4
+ concernCategory: z.string().min(1, 'Concern category is required'),
5
+ concernName: z.string().min(1, 'Concern name is required'),
6
+ severityLevel: z.string().optional(),
7
+ impactLevel: z.string().optional(),
8
+ clinicalNotes: z.string().optional(),
9
+ });
10
+
11
+ export const assessmentScaleSchema = z.object({
12
+ scaleName: z.string().min(1, 'Scale name is required'),
13
+ scaleValue: z.string().min(1, 'Scale value is required'),
14
+ category: z.string().min(1, 'Category is required'),
15
+ });
16
+
17
+ export const patientGoalsSchema = z.object({
18
+ treatmentTimeline: z.string().optional(),
19
+ budgetRange: z.string().optional(),
20
+ naturalnessPreference: z.number().min(0).max(100),
21
+ selectedGoalTemplate: z.string().optional(),
22
+ priorities: z.array(z.string()).default([]),
23
+ });
24
+
25
+ export const aestheticAnalysisSchema = z.object({
26
+ patientId: z.string().min(1, 'Patient ID is required'),
27
+ lastUpdatedBy: z.string().min(1, 'Last updated by is required'),
28
+ lastUpdatedByRole: z.enum(['PATIENT', 'PRACTITIONER']),
29
+ patientGoals: patientGoalsSchema,
30
+ clinicalFindings: z.array(clinicalFindingSchema).default([]),
31
+ assessmentScales: z.array(assessmentScaleSchema).default([]),
32
+ createdAt: z.any(),
33
+ updatedAt: z.any(),
34
+ });
35
+
36
+ export const createAestheticAnalysisSchema = z.object({
37
+ patientGoals: patientGoalsSchema,
38
+ clinicalFindings: z.array(clinicalFindingSchema).default([]),
39
+ assessmentScales: z.array(assessmentScaleSchema).default([]),
40
+ });
41
+
42
+ export const updateAestheticAnalysisSchema = z.object({
43
+ patientGoals: patientGoalsSchema.optional(),
44
+ clinicalFindings: z.array(clinicalFindingSchema).optional(),
45
+ assessmentScales: z.array(assessmentScaleSchema).optional(),
46
+ });
47
+