protected Prescription(PrescriptionIdentifier identifier, HealthcarePractitioner prescriber, Patient patient, HealthFacility healthFacility, Alpha2LanguageCode languageCode, PrescriptionStatus status, DateTime createdOn, DateTime?delivrableAt = null, EntityState entityState = EntityState.Added, IEnumerable <IDomainEvent> events = null) : base(entityState, events) { Condition.Requires(identifier, nameof(identifier)).IsNotNull(); Condition.Requires(prescriber, nameof(prescriber)).IsNotNull(); Condition.Requires(patient, nameof(patient)).IsNotNull(); Condition.Requires(healthFacility, nameof(healthFacility)).IsNotNull(); Condition.Requires(status, nameof(status)).IsNotNull(); Condition.Requires(languageCode, nameof(languageCode)).IsNotNull(); this.Identifier = identifier; this.Prescriber = prescriber; this.Patient = patient; this.HealthFacility = healthFacility; this.Status = status; this.CreatedOn = createdOn; this.DelivrableAt = delivrableAt; this.LanguageCode = languageCode; }
public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier, HealthcarePractitioner prescriber, Patient patient, HealthFacility healthFacility, IEnumerable <PrescribedMedication> prescribedMedications, DateTime createdOn, Alpha2LanguageCode languageCode, DateTime?delivrableAt = null) { var prescription = new PharmaceuticalPrescription ( identifier, prescriber, patient, healthFacility, prescribedMedications, languageCode, PrescriptionStatus.Created, createdOn, delivrableAt ); prescription.AddEvent(new PharmaceuticalPrescriptionCreated(identifier.Value, createdOn)); return(prescription); }
private HealthcarePractitioner AddHealthcarePractitioner(HealthcarePractitioner practitioner) { if (practitioner != default) { if (!_healthcarePractitioners.TryGetValue(practitioner, out HealthcarePractitioner currentPractitioner)) { HashSet <HealthcarePractitioner> healthcarePractitioners = MedicContext.HealthcarePractitioners.Where(hp => hp.UniqueIdentifier == practitioner.UniqueIdentifier).ToHashSet(); currentPractitioner = healthcarePractitioners.FirstOrDefault(p => string.Equals(p.Name, practitioner.Name)); if (currentPractitioner == default) { _healthcarePractitioners.Add(practitioner); } else { _healthcarePractitioners.Add(currentPractitioner); practitioner = currentPractitioner; } } else { practitioner = currentPractitioner; } practitioner.Speciality = AddSpecialtyType(practitioner.Speciality); practitioner.HealthRegion = AddHealthRegion(practitioner.HealthRegion); practitioner.Practice = AddPractice(practitioner.Practice); practitioner.SenderType = AddSenderType(practitioner.SenderType); } return(practitioner); }
public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier, HealthcarePractitioner prescriber, Patient patient, HealthFacility healthFacility, IEnumerable <PrescribedMedication> prescribedMedications, Alpha2LanguageCode languageCode, DateTime?delivrableAt = null) { return(Create(identifier, prescriber, patient, healthFacility, prescribedMedications, DateTime.Now, languageCode, delivrableAt)); }
public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier, HealthcarePractitioner prescriber, Patient patient, IEnumerable <PrescribedMedication> prescribedMedications, Alpha2LanguageCode languageCode, EncounterIdentifier encounterIdentifier = null, DateTime?delivrableAt = null) { return(Create(identifier, prescriber, patient, prescribedMedications, SystemTime.Local(), languageCode, encounterIdentifier, delivrableAt)); }
public PharmaceuticalPrescription(PrescriptionIdentifier identifier, HealthcarePractitioner prescriber, Patient patient, HealthFacility healthFacility, IEnumerable <PrescribedMedication> prescribedMedications, Alpha2LanguageCode languageCode, PrescriptionStatus status, DateTime createdOn, DateTime?delivrableAt = null, EntityState entityState = EntityState.Added, IEnumerable <IDomainEvent> events = null) : base(identifier, prescriber, patient, healthFacility, languageCode, status, createdOn, delivrableAt, entityState, events) { Condition.Requires(prescribedMedications, nameof(prescribedMedications)) .IsNotNull() .IsNotEmpty() .DoesNotContain(null); this.prescribedMedications.AddRange(prescribedMedications); }