Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ItrCode,HospitalId,RegNo,PatientName,PatientFatherName,Age,Sex,Address,MaritalStatus,RefDate,RefTime")] GbvCase gbvCase)
        {
            if (ModelState.IsValid)
            {
                gbvCase.PatientName       = _crypto.Encrypt(gbvCase.PatientName);
                gbvCase.PatientFatherName = _crypto.Encrypt(gbvCase.PatientFatherName);
                gbvCase.GbvCaseId         = Guid.NewGuid();
                gbvCase.UserName          = User.Identity.Name;
                gbvCase.IncCode           = String.Format("{0}-{1}", gbvCase.HospitalId, gbvCase.RegNo);
                gbvCase.InsertDate        = DateTime.Now;
                gbvCase.LastUpdate        = DateTime.Now;
                _context.Add(gbvCase);
                var consent = new Consent();
                consent.GbvCaseId = gbvCase.GbvCaseId;
                _context.Add(consent);
                var reg = new Registration();
                reg.GbvCaseId = gbvCase.GbvCaseId;
                _context.Add(reg);
                var intake = new IntakeInfo();
                intake.GbvCaseId = gbvCase.GbvCaseId;
                _context.Add(intake);
                var auth = new Authorization();
                auth.GbvCaseId = gbvCase.GbvCaseId;
                _context.Add(auth);
                await _context.SaveChangesAsync();

                return(RedirectToAction("edit", "consents", new { id = gbvCase.GbvCaseId }));
            }
            var facilities = _context.FacilityInfo.Where(m => m.User.Equals(User.Identity.Name)).ToList();

            ViewData["HospitalId"] = new SelectList(facilities, "FacilityId", "FacilityName", gbvCase.HospitalId);
            return(View(gbvCase));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("AgencyTypeId,AgencyType1")] AgencyType agencyType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(agencyType);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(agencyType));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("AgencyTypeId,AgencyName,Comment,AuthorizationId,GbvCaseId,Islessthan18,IsSigned,UserName,LastUpdate,InsertDate")] Authorization authorization)
        {
            if (id != authorization.GbvCaseId)
            {
                return(NotFound());
            }
            var item = await _context.Authorization.Include(m => m.GbvCase).AsNoTracking()
                       .SingleOrDefaultAsync(m => m.GbvCase.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name));

            if (item == null)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    var sub = _context.AuthorizationSub.SingleOrDefault(m => m.AuthorizationId == item.AuthorizationId);
                    if (sub == null)
                    {
                        var newSub = new AuthorizationSub();
                        newSub.AgencyTypeId    = authorization.AgencyTypeId;
                        newSub.AgencyName      = authorization.AgencyName;
                        newSub.Comment         = authorization.Comment;
                        newSub.AuthorizationId = authorization.AuthorizationId;
                        _context.AuthorizationSub.Add(newSub);
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        sub.AgencyTypeId = authorization.AgencyTypeId;
                        sub.AgencyName   = authorization.AgencyName;
                        sub.Comment      = authorization.Comment;
                    }
                    item.GbvCase.LastUpdate = DateTime.Now;
                    _context.Update(authorization);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorizationExists(authorization.AuthorizationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("edit", authorization.GbvCaseId));
            }
            return(View(authorization));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ProvCode,Aghchocode,Aimscode,ProvName,ProveNameDari,ProveNamePashto")] Provinces province)
        {
            if (ModelState.IsValid)
            {
                province.CreatedDate = DateTime.Now;
                _context.Add(province);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(province));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("DistCode,DistName,DistNameDari,DistNamePashto,ProvCode")] Districts districts)
        {
            if (ModelState.IsValid)
            {
                districts.CreatedDate = DateTime.Now;
                _context.Add(districts);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ProvCode"] = new SelectList(_context.Provinces, "ProvCode", "ProvName", districts.ProvCode);
            return(View(districts));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Tenant item)
        {
            if (ModelState.IsValid)
            {
                _context.Attach(item);
                _context.Entry(item).State = EntityState.Added;
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("User,FacilityId,ActiveStatus,DateEstablished,DistCode,FacilityName,FacilityNameDari,FacilityNamePashto,FacilityType,Gpslattitude,Gpslongtitude,Implementer,Lat,Location,LocationDari,LocationPashto,Lon,SubImplementer,ViliCode")] FacilityInfo facilityInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(facilityInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            var users = _db.Users.Where(m => m.Active.Equals(true)).Select(m => new ApplicationUser()
            {
                FirstName = m.FirstName + " " + m.LastName + "-" + m.UserName,
                UserName  = m.UserName,
            }).ToList();

            ViewData["User"] = new SelectList(users, "UserName", "FirstName", facilityInfo.User);

            ViewData["DistCode"] = new SelectList(_context.Districts, "DistCode", "DistName", facilityInfo.DistCode);
            return(View(facilityInfo));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(Guid?id, [Bind("RegistrationId,GbvCaseId,RptYear,RptMonth,IsIdp,TypeOfViolence,GbvHistory,RefIn,RefOut,ServiceMedical,ServicePsycho,ServiceRefLegal,ServiceRefSafeHouse,Remarks")] Registration registration)
        {
            if (id != registration.GbvCaseId)
            {
                return(NotFound());
            }

            var item = await _context.Registration.Include(m => m.GbvCase).AsNoTracking().SingleOrDefaultAsync(m => m.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name));

            if (item == null)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    item.GbvCase.LastUpdate = DateTime.Now;
                    _context.Update(registration);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegistrationExists(registration.RegistrationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("edit", new { Guid = registration.GbvCaseId }));
            }
            return(View(registration));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(Guid?id, [Bind("ConsentId,GbvCaseId,PhysicalExams,PelvicExams,SpeculumExams,OtherExams,BloodExams,ProvisionOfInfo")] Consent consent)
        {
            if (id != consent.GbvCaseId)
            {
                return(NotFound());
            }
            var item = await _context.Consent.Include(m => m.GbvCase).AsNoTracking().SingleOrDefaultAsync(m => m.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name));

            if (item == null)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    item.GbvCase.LastUpdate = DateTime.Now;
                    _context.Update(consent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsentExists(consent.ConsentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Edit", new { Guid = consent.GbvCaseId }));
            }
            ViewData["GbvCaseId"] = new SelectList(_context.GbvCase, "GbvCaseId", "GbvCaseId", consent.GbvCaseId);
            return(View(consent));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Edit(Guid id, [Bind("formtype,IntakeInfoId,GbvCaseId,ReferredBy,RefOther,ExamDate,ExamTime,IncDate,IncTime,IncLocation,IncLocationOther,IncType,IncReportToOther,Relationship,NoOfPerpetrators,PerpetratorOccupation,OccupationOther,AgeGroup,StiStatus,HcvHbs,EvidenceOfPregnancy,PregnancyWeeks,Results,ResultsOther,PsychologicalStatus,ExaminedForAids,SstPrevenMed,MedForInjuries,VacForTreat,ReferToPsychosocial,ReferToHigherMedical,YesBetterFacilities,YesFpservices,YesVaccination,YesConsulation,YesVct,YesPregnancyTest,YesOther,NoServiceProvided,NoServiceAccepted,NoServiceAvailable,RefFpcenter,Mowadowa,Aihrc,SafeHouse,BackHome,Other,OtherSpecify,RefNotAvailable,RefNotAccepted,IsSurvivorWilling,EvidenceCollected,MedicalCertificate,Appointment,MedExamProcedure,ConsentTaken,SpreadInfo")] IntakeInfo info)
        {
            if (id != info.GbvCaseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var item = _context.IntakeInfo.Where(m => m.GbvCaseId.Equals(info.GbvCaseId)).Include(m => m.GbvCase).AsNoTracking().SingleOrDefault();
                if (!item.GbvCase.UserName.Equals(User.Identity.Name))
                {
                    return(NotFound());
                }
                if (info.formtype == 1)
                {
                    item.ReferredBy = info.ReferredBy;
                    item.RefOther   = info.RefOther;
                    item.ExamDate   = info.ExamDate;
                    item.ExamTime   = info.ExamTime;
                }
                if (info.formtype == 2)
                {
                    item.IncLocation      = info.IncLocation;
                    item.IncType          = info.IncType;
                    item.IncLocationOther = info.IncLocationOther;
                    item.IncReportToOther = info.IncReportToOther;
                    item.IncDate          = info.IncDate;
                    item.IncTime          = info.IncTime;
                }
                if (info.formtype == 3)
                {
                    item.Relationship          = info.Relationship;
                    item.NoOfPerpetrators      = info.NoOfPerpetrators;
                    item.PerpetratorOccupation = info.PerpetratorOccupation;
                    item.OccupationOther       = info.OccupationOther;
                }
                if (info.formtype == 4)
                {
                    item.AgeGroup            = info.AgeGroup;
                    item.StiStatus           = info.StiStatus;
                    item.HcvHbs              = info.HcvHbs;
                    item.EvidenceOfPregnancy = info.EvidenceOfPregnancy;
                    item.PregnancyWeeks      = info.PregnancyWeeks;
                    item.Results             = info.Results;
                    item.ResultsOther        = info.ResultsOther;
                    item.PsychologicalStatus = info.PsychologicalStatus;
                    item.ExaminedForAids     = info.ExaminedForAids;
                }
                if (info.formtype == 5)
                {
                    item.SstPrevenMed   = info.SstPrevenMed;
                    item.MedForInjuries = info.MedForInjuries;
                    item.VacForTreat    = info.VacForTreat;
                }
                if (info.formtype == 6)
                {
                    item.ReferToPsychosocial  = info.ReferToPsychosocial;
                    item.ReferToHigherMedical = info.ReferToHigherMedical;
                    item.YesBetterFacilities  = info.YesBetterFacilities;
                    item.YesFpservices        = info.YesFpservices;
                    item.YesVaccination       = info.YesVaccination;
                    item.YesConsulation       = info.YesConsulation;
                    item.YesVct             = info.YesVct;
                    item.YesPregnancyTest   = info.YesPregnancyTest;
                    item.YesOther           = info.YesOther;
                    item.NoServiceProvided  = info.NoServiceProvided;
                    item.NoServiceAvailable = info.NoServiceAvailable;
                    item.NoServiceAccepted  = info.NoServiceAccepted;
                }
                if (info.formtype == 7)
                {
                    item.RefFpcenter        = info.RefFpcenter;
                    item.Mowadowa           = info.Mowadowa;
                    item.Aihrc              = info.Aihrc;
                    item.SafeHouse          = info.SafeHouse;
                    item.BackHome           = info.BackHome;
                    item.Other              = info.Other;
                    item.RefNotAvailable    = info.RefNotAvailable;
                    item.RefNotAccepted     = info.RefNotAccepted;
                    item.OtherSpecify       = info.OtherSpecify;
                    item.IsSurvivorWilling  = info.IsSurvivorWilling;
                    item.EvidenceCollected  = info.EvidenceCollected;
                    item.MedicalCertificate = info.MedicalCertificate;
                    item.Appointment        = info.Appointment;
                    item.MedExamProcedure   = info.MedExamProcedure;
                    item.ConsentTaken       = info.ConsentTaken;
                    item.SpreadInfo         = info.SpreadInfo;
                }
                try
                {
                    item.GbvCase.LastUpdate = DateTime.Now;
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IntakeInfoExists(info.IntakeInfoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Ok("success"));
            }
            return(View(info));
        }