예제 #1
0
        private async Task <bool> ExtractAll(LoadFromEmrCommand request, CancellationToken cancellationToken)
        {
            // ExtractPatientART
            var patientArtProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientArtExtract");
            var patientArtCommand = new ExtractPatientArt()
            {
                Extract          = patientArtProfile?.Extract,
                DatabaseProtocol = patientArtProfile?.DatabaseProtocol
            };

            // ExtractPatientBaselines
            var patientBaselinesProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientBaselineExtract");
            var patientBaselinesCommand = new ExtractPatientBaselines()
            {
                Extract          = patientBaselinesProfile?.Extract,
                DatabaseProtocol = patientBaselinesProfile?.DatabaseProtocol
            };

            // ExtractPatientLaboratory
            var patientLaboratoryProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientLabExtract");
            var patientLaboratoryCommand = new ExtractPatientLaboratory()
            {
                Extract          = patientLaboratoryProfile?.Extract,
                DatabaseProtocol = patientLaboratoryProfile?.DatabaseProtocol
            };

            // ExtractPatientPharmacy
            var patientPharmacyProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientPharmacyExtract");
            var patientPharmacyCommand = new ExtractPatientPharmacy()
            {
                Extract          = patientPharmacyProfile?.Extract,
                DatabaseProtocol = patientPharmacyProfile?.DatabaseProtocol
            };

            // ExtractPatientStatus
            var patientStatusProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientStatusExtract");
            var patientStatusCommand = new ExtractPatientStatus()
            {
                Extract          = patientStatusProfile?.Extract,
                DatabaseProtocol = patientStatusProfile?.DatabaseProtocol
            };

            // ExtractPatientVisit
            var patientVisitProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientVisitExtract");
            var patientVisitCommand = new ExtractPatientVisit()
            {
                Extract          = patientVisitProfile?.Extract,
                DatabaseProtocol = patientVisitProfile?.DatabaseProtocol
            };

            var t1 = _mediator.Send(patientArtCommand, cancellationToken);
            var t2 = _mediator.Send(patientBaselinesCommand, cancellationToken);
            var t3 = _mediator.Send(patientLaboratoryCommand, cancellationToken);
            var t4 = _mediator.Send(patientPharmacyCommand, cancellationToken);
            var t5 = _mediator.Send(patientStatusCommand, cancellationToken);
            var t6 = _mediator.Send(patientVisitCommand, cancellationToken);

            var ts = new List <Task <bool> > {
                t1, t2, t3, t4, t5, t6
            };

            var result = await Task.WhenAll(ts);

            return(result.All(x => x));
        }
예제 #2
0
        private async Task <bool> ExtractAll(LoadFromEmrCommand request, CancellationToken cancellationToken)
        {
            var ts1 = new List <Task <bool> >();
            var ts2 = new List <Task <bool> >();
            var ts3 = new List <Task <bool> >();
            var ts4 = new List <Task <bool> >();
            var ts5 = new List <Task <bool> >();
            var ts6 = new List <Task <bool> >();

            var ts7 = new List <Task <bool> >();
            var ts8 = new List <Task <bool> >();

            // ExtractPatientART
            var patientArtProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientArtExtract");

            if (null != patientArtProfile)
            {
                var patientArtCommand = new ExtractPatientArt()
                {
                    Extract          = patientArtProfile?.Extract,
                    DatabaseProtocol = patientArtProfile?.DatabaseProtocol
                };
                ts1.Add(_mediator.Send(patientArtCommand, cancellationToken));
            }

            // ExtractPatientBaselines
            var patientBaselinesProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientBaselineExtract");

            if (null != patientBaselinesProfile)
            {
                var patientBaselinesCommand = new ExtractPatientBaselines()
                {
                    Extract          = patientBaselinesProfile?.Extract,
                    DatabaseProtocol = patientBaselinesProfile?.DatabaseProtocol
                };
                ts1.Add(_mediator.Send(patientBaselinesCommand, cancellationToken));
            }

            // ExtractPatientLaboratory
            var patientLaboratoryProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientLabExtract");

            if (null != patientLaboratoryProfile)
            {
                var patientLaboratoryCommand = new ExtractPatientLaboratory()
                {
                    Extract          = patientLaboratoryProfile?.Extract,
                    DatabaseProtocol = patientLaboratoryProfile?.DatabaseProtocol
                };
                ts1.Add(_mediator.Send(patientLaboratoryCommand, cancellationToken));
            }

            // ExtractPatientPharmacy
            var patientPharmacyProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientPharmacyExtract");

            if (null != patientPharmacyProfile)
            {
                var patientPharmacyCommand = new ExtractPatientPharmacy()
                {
                    Extract          = patientPharmacyProfile?.Extract,
                    DatabaseProtocol = patientPharmacyProfile?.DatabaseProtocol
                };
                ts2.Add(_mediator.Send(patientPharmacyCommand, cancellationToken));
            }

            // ExtractPatientStatus
            var patientStatusProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientStatusExtract");

            if (null != patientStatusProfile)
            {
                var patientStatusCommand = new ExtractPatientStatus()
                {
                    Extract          = patientStatusProfile?.Extract,
                    DatabaseProtocol = patientStatusProfile?.DatabaseProtocol
                };
                ts2.Add(_mediator.Send(patientStatusCommand, cancellationToken));
            }

            // ExtractPatientVisit
            var patientVisitProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientVisitExtract");

            if (null != patientVisitProfile)
            {
                var patientVisitCommand = new ExtractPatientVisit()
                {
                    Extract          = patientVisitProfile?.Extract,
                    DatabaseProtocol = patientVisitProfile?.DatabaseProtocol
                };
                ts2.Add(_mediator.Send(patientVisitCommand, cancellationToken));
            }

            // ExtractPatientAdverseEvent
            var patientAdverseEventProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "PatientAdverseEventExtract");

            if (null != patientAdverseEventProfile)
            {
                var patientAdverseEventCommand = new ExtractPatientAdverseEvent()
                {
                    Extract          = patientAdverseEventProfile?.Extract,
                    DatabaseProtocol = patientAdverseEventProfile?.DatabaseProtocol
                };
                ts3.Add(_mediator.Send(patientAdverseEventCommand, cancellationToken));
            }


            // ExtractAllergiesChronicIllness
            var allergiesChronicIllnessProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "AllergiesChronicIllnessExtract");

            if (null != allergiesChronicIllnessProfile)
            {
                var allergiesChronicIllnessCommand = new ExtractAllergiesChronicIllness()
                {
                    Extract          = allergiesChronicIllnessProfile?.Extract,
                    DatabaseProtocol = allergiesChronicIllnessProfile?.DatabaseProtocol
                };
                ts3.Add(_mediator.Send(allergiesChronicIllnessCommand, cancellationToken));
            }

            // ExtractContactListing
            var contactListingProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "ContactListingExtract");

            if (null != contactListingProfile)
            {
                var contactListingCommand = new ExtractContactListing()
                {
                    Extract          = contactListingProfile?.Extract,
                    DatabaseProtocol = contactListingProfile?.DatabaseProtocol
                };
                ts3.Add(_mediator.Send(contactListingCommand, cancellationToken));
            }

            // ExtractDepressionScreening
            var depressionScreeningProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "DepressionScreeningExtract");

            if (null != depressionScreeningProfile)
            {
                var depressionScreeningCommand = new ExtractDepressionScreening()
                {
                    Extract          = depressionScreeningProfile?.Extract,
                    DatabaseProtocol = depressionScreeningProfile?.DatabaseProtocol
                };
                ts4.Add(_mediator.Send(depressionScreeningCommand, cancellationToken));
            }

            // ExtractDrugAlcoholScreening
            var drugAlcoholScreeningProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "DrugAlcoholScreeningExtract");

            if (null != drugAlcoholScreeningProfile)
            {
                var drugAlcoholScreeningCommand = new ExtractDrugAlcoholScreening()
                {
                    Extract          = drugAlcoholScreeningProfile?.Extract,
                    DatabaseProtocol = drugAlcoholScreeningProfile?.DatabaseProtocol
                };
                ts4.Add(_mediator.Send(drugAlcoholScreeningCommand, cancellationToken));
            }

            // ExtractEnhancedAdherenceCounselling
            var enhancedAdherenceCounsellingProfile =
                request.Extracts.FirstOrDefault(x => x.Extract.Name == "EnhancedAdherenceCounsellingExtract");

            if (null != enhancedAdherenceCounsellingProfile)
            {
                var enhancedAdherenceCounsellingCommand = new ExtractEnhancedAdherenceCounselling()
                {
                    Extract          = enhancedAdherenceCounsellingProfile?.Extract,
                    DatabaseProtocol = enhancedAdherenceCounsellingProfile?.DatabaseProtocol
                };
                ts4.Add(_mediator.Send(enhancedAdherenceCounsellingCommand, cancellationToken));
            }

            // ExtractGbvScreening
            var gbvScreeningProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "GbvScreeningExtract");

            if (null != gbvScreeningProfile)
            {
                var gbvScreeningCommand = new ExtractGbvScreening()
                {
                    Extract          = gbvScreeningProfile?.Extract,
                    DatabaseProtocol = gbvScreeningProfile?.DatabaseProtocol
                };
                ts5.Add(_mediator.Send(gbvScreeningCommand, cancellationToken));
            }

            // ExtractIpt
            var iptProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "IptExtract");

            if (null != iptProfile)
            {
                var iptCommand = new ExtractIpt()
                {
                    Extract          = iptProfile?.Extract,
                    DatabaseProtocol = iptProfile?.DatabaseProtocol
                };
                ts5.Add(_mediator.Send(iptCommand, cancellationToken));
            }


            // ExtractOtz
            var otzProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "OtzExtract");

            if (null != otzProfile)
            {
                var otzCommand = new ExtractOtz()
                {
                    Extract          = otzProfile?.Extract,
                    DatabaseProtocol = otzProfile?.DatabaseProtocol
                };
                ts5.Add(_mediator.Send(otzCommand, cancellationToken));
            }

            // ExtractOvc
            var ovcProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "OvcExtract");

            if (null != ovcProfile)
            {
                var ovcCommand = new ExtractOvc()
                {
                    Extract          = ovcProfile?.Extract,
                    DatabaseProtocol = ovcProfile?.DatabaseProtocol
                };
                ts6.Add(_mediator.Send(ovcCommand, cancellationToken));
            }

            // ExtractCovid
            var covidProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "CovidExtract");

            if (null != covidProfile)
            {
                var covidCommand = new ExtractCovid()
                {
                    Extract          = covidProfile?.Extract,
                    DatabaseProtocol = covidProfile?.DatabaseProtocol
                };
                ts7.Add(_mediator.Send(covidCommand, cancellationToken));
            }

            // ExtractDefaulterTracing
            var defaulterTracingProfile = request.Extracts.FirstOrDefault(x => x.Extract.Name == "DefaulterTracingExtract");

            if (null != defaulterTracingProfile)
            {
                var defaulterTracingCommand = new ExtractDefaulterTracing()
                {
                    Extract          = defaulterTracingProfile?.Extract,
                    DatabaseProtocol = defaulterTracingProfile?.DatabaseProtocol
                };
                ts8.Add(_mediator.Send(defaulterTracingCommand, cancellationToken));
            }

            var result1 = await Task.WhenAll(ts1);

            var result2 = await Task.WhenAll(ts2);

            var result3 = await Task.WhenAll(ts3);

            var result4 = await Task.WhenAll(ts4);

            var result5 = await Task.WhenAll(ts5);

            var result6 = await Task.WhenAll(ts6);

            var result7 = await Task.WhenAll(ts7);

            var result8 = await Task.WhenAll(ts8);

            var result = new List <bool>();

            result.AddRange(result1);
            result.AddRange(result2);
            result.AddRange(result3);
            result.AddRange(result4);
            result.AddRange(result5);
            result.AddRange(result6);

            result.AddRange(result7);
            result.AddRange(result8);

            return(result.All(x => x));
        }