public override void Execute() { try { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] Loading MedicationMaps.", IsError = false }); List <EMedicationMap> pharmClassMap = new List <EMedicationMap>(); ConcurrentBag <EMedicationMap> eMeds = new ConcurrentBag <EMedicationMap>(); ConcurrentBag <MEMedicationMapping> meds; using (MedicationMongoContext smct = new MedicationMongoContext(Contract)) { meds = new ConcurrentBag <MEMedicationMapping>(smct.MedicationMaps.Collection.FindAllAs <MEMedicationMapping>().ToList()); } Parallel.ForEach(meds, med => //foreach (MEMedicationMapping med in meds)//.Where(t => !t.DeleteFlag )) { try { eMeds.Add(new EMedicationMap { MongoId = med.Id.ToString(), Form = med.Form, FullName = med.FullName, Route = med.Route, Strength = med.Strength, SubstanceName = med.SubstanceName, Version = med.Version, MongoUpdatedBy = med.UpdatedBy == null ? string.Empty : med.UpdatedBy.ToString(), MongoRecordCreatedBy = med.RecordCreatedBy.ToString(), RecordCreatedOn = med.RecordCreatedOn, DeleteFlag = med.DeleteFlag, Custom = med.Custom, Verified = med.Verified, TTLDate = med.TTLDate, LastUpdatedOn = med.LastUpdatedOn }); } catch (Exception ex) { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] " + ex.Message + ": " + ex.StackTrace, IsError = true }); } }); SaveSubcollection(eMeds); } catch (Exception ex) { throw ex; //SimpleLog.Log(new ArgumentException("LoadPatientPrograms()", ex)); } }
public static IMongoMedicationRepository GetMedicationRepository(IDataDomainRequest request, RepositoryType type) { try { IMongoMedicationRepository repo = null; switch (type) { case RepositoryType.PatientMedSupp: { var context = new MedicationMongoContext(request.ContractNumber); repo = new StubPatientMedSuppRepository <MedicationMongoContext>(context) { UserId = request.UserId, ContractDBName = request.ContractNumber }; break; } case RepositoryType.Medication: { var context = new MedicationMongoContext(request.ContractNumber); repo = new StubMedicationRepository <MedicationMongoContext>(context) { UserId = request.UserId, ContractDBName = request.ContractNumber }; break; } case RepositoryType.MedicationMapping: { var context = new MedicationMongoContext(request.ContractNumber); repo = new StubMedicationMappingRepository <MedicationMongoContext>(context) { UserId = request.UserId, ContractDBName = request.ContractNumber }; break; } } return(repo); } catch (Exception ex) { throw ex; } }
public override void Execute() { try { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] Loading Medication.", IsError = false }); ConcurrentBag <EPharmClass> pharmClassMap = new ConcurrentBag <EPharmClass>(); ConcurrentBag <EMedication> eMeds = new ConcurrentBag <EMedication>(); ConcurrentBag <MEMedication> meds; using (MedicationMongoContext smct = new MedicationMongoContext(Contract)) { meds = new ConcurrentBag <MEMedication>(smct.Medications.Collection.FindAllAs <MEMedication>().ToList()); } Parallel.ForEach(meds, med => //foreach (MEMedication med in meds)//.Where(t => !t.DeleteFlag )) { try { eMeds.Add(new EMedication { Id = med.Id.ToString(), EndDate = med.EndDate, FamilyId = med.FamilyId == null ? string.Empty : med.FamilyId.ToString(), Form = med.Form, FullName = med.FullName, NDC = med.NDC, ProductId = med.ProductId, ProprietaryName = med.ProprietaryName, ProprietaryNameSuffix = med.ProprietaryNameSuffix, Route = med.Route, StartDate = med.StartDate, Strength = med.Strength, SubstanceName = med.SubstanceName, Unit = med.Unit, Version = med.Version, MongoUpdatedBy = med.UpdatedBy == null ? string.Empty : med.UpdatedBy.ToString(), LastUpdatedOn = med.LastUpdatedOn, RecordCreatedBy = med.RecordCreatedBy.ToString(), RecordCreatedOn = med.RecordCreatedOn, TTLDate = med.TTLDate, DeleteFlag = med.DeleteFlag }); } catch (Exception ex) { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] " + ex.Message + ": " + ex.StackTrace, IsError = true }); } if (med.PharmClass != null) { foreach (string pc in med.PharmClass) { if (!string.IsNullOrEmpty(pc)) { pharmClassMap.Add(new EPharmClass { MedMongoId = med.Id.ToString(), PharmClass = pc }); } } } }); SaveSubcollection(eMeds); SavePharmClasses(pharmClassMap); } catch (Exception ex) { throw ex; //SimpleLog.Log(new ArgumentException("LoadPatientPrograms()", ex)); } }
public override void Execute() { try { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] Loading Patient Medication Frequency.", IsError = false }); ConcurrentBag <EMedicationFrequency> medFreq = new ConcurrentBag <EMedicationFrequency>(); ConcurrentBag <EPatientMedicationFrequency> custMedFreq = new ConcurrentBag <EPatientMedicationFrequency>(); var mType = "Frequency"; Parallel.ForEach(LookUp.Data, l => //foreach (LookUpBase l in LookUp.Data)//.Where(t => !t.DeleteFlag )) { try { var prb = (Frequency)l; medFreq.Add(new EMedicationFrequency { LookUpType = mType, MongoId = prb.DataId.ToString(), Name = prb.Name, }); } catch (Exception ex) { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] " + ex.Message + ": " + ex.StackTrace, IsError = true }); } }); ConcurrentBag <MEPatientMedFrequency> meds; using (MedicationMongoContext smct = new MedicationMongoContext(Contract)) { meds = new ConcurrentBag <MEPatientMedFrequency>(smct.PatientMedFrequencies.Collection.FindAllAs <MEPatientMedFrequency>().ToList()); } Parallel.ForEach(meds, med => //foreach (MEPatientMedFrequency med in meds)//.Where(t => !t.DeleteFlag )) { try { custMedFreq.Add(new EPatientMedicationFrequency { Name = med.Name, MongoPatientId = med.PatientId == null ? string.Empty : med.PatientId.ToString(), Version = med.Version, MongoUpdatedBy = med.UpdatedBy == null ? string.Empty : med.UpdatedBy.ToString(), DeleteFlag = med.DeleteFlag, MongoRecordCreatedBy = med.RecordCreatedBy == null ? string.Empty : med.RecordCreatedBy.ToString(), RecordCreatedOn = med.RecordCreatedOn, TTLDate = med.TTLDate, MongoId = med.Id == null ? string.Empty : med.Id.ToString(), LookUpType = mType }); } catch (Exception ex) { OnDocColEvent(new ETLEventArgs { Message = "[" + Contract + "] " + ex.Message + ": " + ex.StackTrace, IsError = true }); } }); SaveSubcollection(medFreq); SaveCustomSubcollection(custMedFreq); } catch (Exception ex) { throw ex; //SimpleLog.Log(new ArgumentException("LoadPatientPrograms()", ex)); } }