Ejemplo n.º 1
0
        public NewPatientRecordViewModel CreateNewRecord(PatientRecordModel vm)
        {
            NewPatientRecordViewModel result           = new NewPatientRecordViewModel();
            PractitionerData          practitionerData = new PractitionerData();
            PatientData patientData = new PatientData();

            //Retrieve practitioner and company information
            PractitionerBaseViewModel practitionerId = new PractitionerBaseViewModel();

            practitionerId.AccId       = vm.PractitionerId;
            result.PractitionerDetails = practitionerData.GetProfile(practitionerId);

            // Retrieve patient information
            result.PatientDetails = patientData.PatientProfile(vm.PatientId);

            vm.CreatedOn = DateTime.UtcNow;

            RecordFileSystem fileRecord = new RecordFileSystem();

            fileRecord.ContentType      = ConstantHelper.AppSettings.RecordFileType;
            fileRecord.FileContents     = new byte[1];
            fileRecord.FileDownloadname = DateTime.Now.Date.ToString() + "-" + result.PractitionerDetails.CompanyId;
            fileRecord.PatientId        = result.PatientDetails.AccId;
            fileRecord.PractitionerId   = result.PractitionerDetails.AccId;

            //Get medicines list in the company
            result.NewPatientRecord = practitionerData.GetMedicinesList(result.PractitionerDetails.CompanyId);
            result.NewPatientRecord.AppointmentId  = vm.AppointmentId;
            result.NewPatientRecord.PatientId      = vm.PatientId;
            result.NewPatientRecord.PractitionerId = vm.PractitionerId;

            //Creating a record in the database
            result.NewPatientRecord.RecordId = practitionerData.CreatePatientRecord(fileRecord);

            return(result);
        }