using adas_core.Domain.Enums; using adas_core.Domain.Models; using adas_core.Infrastructure.Utils.MongoMaps.Interfaz; using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; namespace adas_core.Infrastructure.Utils.MongoMaps; public class AppointmentMapContributor : IEntityMapContributor { public void RegisterMaps() { if (!BsonClassMap.IsClassMapRegistered(typeof(PatientAppointment))) BsonClassMap.RegisterClassMap(cm => { cm.AutoMap(); cm.MapIdMember(c => c.Id).SetElementName("_id"); cm.MapMember(c => c.PatientId).SetSerializer(new ObjectIdSerializer(BsonType.String)); cm.MapMember(c => c.Patient).SetIgnoreIfNull(true); cm.MapMember(c => c.Timings).SetDefaultValue(new List()); cm.MapMember(c => c.CreateTime).SetIgnoreIfNull(true); cm.MapMember(c => c.UpdateTime).SetIgnoreIfNull(true); cm.MapMember(c => c.PlacerOrder).SetIgnoreIfNull(true); cm.MapMember(c => c.FillerOrder).SetIgnoreIfNull(true); cm.MapMember(c => c.EventReason).SetIgnoreIfNull(true); cm.MapMember(c => c.AppointmentReason).SetIgnoreIfNull(true); cm.MapMember(c => c.AppointmentType).SetIgnoreIfNull(true); cm.MapMember(c => c.AppointmentOperationType) .SetIgnoreIfNull(true) .SetSerializer( new NullableSerializer(new EnumSerializer(BsonType.String))); cm.MapMember(c => c.AppointmentStatus) .SetIgnoreIfNull(true) .SetSerializer( new NullableSerializer(new EnumSerializer(BsonType.String))); cm.MapMember(c => c.Duration).SetIgnoreIfNull(true); cm.MapMember(c => c.VisitNumber).SetIgnoreIfNull(true); cm.MapMember(c => c.PatientClass).SetIgnoreIfNull(true); cm.MapMember(c => c.EpisodeActivation).SetDefaultValue(true); cm.MapMember(c => c.PlacerContact).SetIgnoreIfNull(true); cm.MapMember(c => c.FillerContact).SetIgnoreIfNull(true); cm.MapMember(c => c.ResourceGroups).SetDefaultValue(new List()); cm.MapMember(c => c.Allergies).SetDefaultValue(new List()); }); if (!BsonClassMap.IsClassMapRegistered(typeof(PatientAppointmentResourceGroup))) BsonClassMap.RegisterClassMap(cm => { cm.AutoMap(); cm.MapMember(c => c.Services).SetIgnoreIfNull(true); cm.MapMember(c => c.Resources).SetIgnoreIfNull(true); cm.MapMember(c => c.Locations).SetIgnoreIfNull(true); cm.MapMember(c => c.Personnel).SetIgnoreIfNull(true); cm.UnmapMember(c => c.ServicesActions); cm.UnmapMember(c => c.ResourcesActions); cm.UnmapMember(c => c.LocationsActions); cm.UnmapMember(c => c.PersonnelActions); }); if (!BsonClassMap.IsClassMapRegistered(typeof(Allergies))) BsonClassMap.RegisterClassMap(cm => { cm.AutoMap(); cm.MapMember(c => c.AllergenType).SetIgnoreIfNull(true); cm.MapMember(c => c.Allergen).SetIgnoreIfNull(true); }); } }