public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier,
                                                        HealthcareProvider 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.Identifier, createdOn));
            return(prescription);
        }
Exemple #2
0
 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;
 }
Exemple #3
0
        public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier,
                                                        HealthcarePractitioner prescriber,
                                                        Patient patient,
                                                        IEnumerable <PrescribedMedication> prescribedMedications,
                                                        DateTime createdOn,
                                                        Alpha2LanguageCode languageCode,
                                                        EncounterIdentifier encounterIdentifier = null,
                                                        DateTime?delivrableAt = null)
        {
            var prescription = new PharmaceuticalPrescription
                               (
                identifier,
                prescriber,
                patient,
                prescribedMedications,
                languageCode,
                PrescriptionStatus.Created,
                createdOn,
                encounterIdentifier,
                delivrableAt
                               );

            prescription.AddEvent(new PharmaceuticalPrescriptionCreated(identifier.Value, createdOn));
            return(prescription);
        }
 public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier,
                                                 HealthcareProvider prescriber,
                                                 Patient patient,
                                                 HealthFacility healthFacility,
                                                 IEnumerable <PrescribedMedication> prescribedMedications,
                                                 Alpha2LanguageCode languageCode,
                                                 DateTime?delivrableAt = null)
 {
     return(Create(identifier, prescriber, patient, healthFacility, prescribedMedications, DateTime.Now, languageCode, delivrableAt));
 }
Exemple #5
0
 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,
                                   HealthcareProvider 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);
 }
Exemple #7
0
        public IEnumerable <PharmaceuticalPrescription> Translate(CreatePharmaceuticalPrescriptions command)
        {
            Condition.Requires(command, nameof(command)).IsNotNull();
            var provider     = ToProvider(command);
            var patient      = ToPatient(command);
            var facility     = ToHealthFacility(command);
            var languageCode = new Alpha2LanguageCode(command.LanguageCode);

            foreach (var prescription in command.Prescriptions)
            {
                yield return(PharmaceuticalPrescription.Create
                             (
                                 new PrescriptionIdentifier(prescription.PrescriptionIdentifier),
                                 provider,
                                 patient,
                                 facility,
                                 prescription.Medications.Select(m => ToPrescribedMedication(m)),
                                 prescription.CreatedOn,
                                 languageCode,
                                 prescription.DelivrableAt
                             ));
            }
        }