Пример #1
0
        public string MoveFile(string path, string file, string targetFile, string chartId, MWPAT patient, Doctor doctor)
        {

            file = file.Replace("\\\\" + System.Net.Dns.GetHostName() + "\\" + this.data["DRR_DRIVE"] + "$", this.data["DRR_DRIVE"] + ":"); //this is not good for deploying to another machine moving project to another machine
            string toReturn = file;
            bool isPatient = false;
            bool isIncoming = false;
             
            if (this.isPatientFolder(path))
            {
                if (chartId == null)
                {

                    Dictionary<string, string> d = getFileMetaData(file);

                    if (d!= null && d.ContainsKey(IndividualRFileInfo.CHART_ID) )
                    {
                        chartId = d[IndividualRFileInfo.CHART_ID];
                    
                    }
                    else
                    {
                        return "File has no chart Id";
                    }
                }
                
                path = data["ROUTING_BASE"] + chartId + Path.DirectorySeparatorChar + path;
                DirectoryInfo dInfo = new DirectoryInfo(path);
                dInfo.Create();
                isPatient = true;
            }
            if (this.isIncomingFolder(path))
            {
                isIncoming = true;
            }
            if (System.IO.Directory.Exists(path) && System.IO.File.Exists(file) && !IsFileLocked(new IndividualRFileInfo(file)))
            {
                System.IO.FileInfo destinationFile = new System.IO.FileInfo(path + Path.DirectorySeparatorChar + targetFile);
                toReturn = targetFile;
                FileInfo sourceFile = new FileInfo(file);
                FileInfo targetPath = new FileInfo(path + Path.DirectorySeparatorChar + targetFile);
                if (targetPath.FullName != sourceFile.FullName && !System.IO.File.Exists(path + Path.DirectorySeparatorChar + targetFile))
                {

                    System.IO.File.Copy(file, path + Path.DirectorySeparatorChar + targetFile, true);
                    System.IO.File.Copy(file, data["DRR_BACKUP_FOLDER"] + Path.DirectorySeparatorChar + targetFile, true);
                    if (System.IO.File.Exists(path + Path.DirectorySeparatorChar + targetFile))
                    {
                        System.IO.File.Delete(file);
                        file = file.Replace(".pdf", ".png");

                        destinationFile = new System.IO.FileInfo(destinationFile.Directory.FullName + Path.DirectorySeparatorChar + targetFile.Replace(".pdf", ".png"));
                        if (destinationFile.Exists)
                        {
                            if (isPatient)
                            {
                                System.IO.File.Delete(file);
                            }
                            else if (isIncoming && System.IO.Directory.Exists(file))
                            {
                                System.IO.File.Move(file, path + destinationFile.Name);
                            }
                        }
                        chartId = this.getValue(this.GetFileChartInformation(path + Path.DirectorySeparatorChar + targetFile), IndividualRFileInfo.CHART_ID);
                        toReturn = "Moved " + toReturn + " (" + chartId + ") \nto " + path + "  Successfully";
                        this.setMetaData(destinationFile.Directory.FullName + Path.DirectorySeparatorChar + targetFile, IndividualRFileInfo.CURRENT_DIRECTORY, destinationFile.Directory.Name);
                         
                        this.SetPatientInformation(patient, doctor, destinationFile.Directory.FullName + Path.DirectorySeparatorChar + targetFile);
                    }
                }
                else if (System.IO.File.Exists(path + Path.DirectorySeparatorChar + targetFile))
                {
                    toReturn = "A file with the same name exists in the target folder. Please use a different name.";

                }
                else if (targetPath.FullName != sourceFile.FullName)
                {
                    chartId = this.getValue(this.GetFileChartInformation(path + Path.DirectorySeparatorChar + targetFile), IndividualRFileInfo.CHART_ID);
                    toReturn = "Moved " + toReturn + " (" + chartId + ") \nto " + path + "  Successfully";
                }
                else
                {
                    toReturn += " can't be moved";
                }
            }
            else if (!System.IO.Directory.Exists(path))
            {
                toReturn += "Directory doesn't exist";
            }
            else if (!System.IO.File.Exists(file))
            {
                toReturn += " doesn't exist";
            }
            else if (IsFileLocked(new IndividualRFileInfo(file)))
            {
                toReturn += " is in use";
            }
            return toReturn;
        }
Пример #2
0
        private void SetPatientInformation(MWPAT patient, Doctor doc, string filePath)
        {
            Dictionary<string, string> allInformation = new Dictionary<string, string>();
            if (patient != null)  
            {
                allInformation.Add(IndividualRFileInfo.CHART_ID, patient.ChartNumber);
                allInformation.Add(IndividualRFileInfo.FIRST_NAME, patient.FirstName);
                allInformation.Add(IndividualRFileInfo.MIDDLE_INITIAL, "" + patient.MiddleInitial);
                allInformation.Add(IndividualRFileInfo.LAST_NAME, patient.LastName);
                allInformation.Add(IndividualRFileInfo.CITY, patient.City);
                allInformation.Add(IndividualRFileInfo.STATE, patient.State);
                allInformation.Add(IndividualRFileInfo.STREET_1, patient.Street1);
                allInformation.Add(IndividualRFileInfo.STREET_2, patient.Street2);
                allInformation.Add(IndividualRFileInfo.ZIP_CODE, patient.ZipCode);
                if(patient.DateOfBirth != null){
                    allInformation.Add(IndividualRFileInfo.DATE_OF_BIRTH, ((DateTime)patient.DateOfBirth).ToShortDateString());
                }
                
            }
            if(doc != null){
                allInformation.Add(IndividualRFileInfo.DOCTOR_FIRST_NAME, doc.FirstName);
                allInformation.Add(IndividualRFileInfo.DOCTOR_LAST_NAME, doc.LastName);
                allInformation.Add(IndividualRFileInfo.DOCTOR_MIDDLE_INITIAL, doc.MiddleName);
                allInformation.Add(IndividualRFileInfo.DOCTOR_PHONE_1, doc.Tel1);
                allInformation.Add(IndividualRFileInfo.DOCTOR_STREET_1, doc.Address1);
                allInformation.Add(IndividualRFileInfo.DOCTOR_STREET_2, doc.Address2);
                allInformation.Add(IndividualRFileInfo.DOCTOR_STREET_3, doc.Address3);
                allInformation.Add(IndividualRFileInfo.DOCTOR_FAX, doc.Fax);
                allInformation.Add(IndividualRFileInfo.DOCTOR_CITY, doc.City);
                allInformation.Add(IndividualRFileInfo.DOCTOR_STATE, doc.State);
                allInformation.Add(IndividualRFileInfo.DOCTOR_ZIP_CODE, doc.Zipcode);
                allInformation.Add(IndividualRFileInfo.DOCTOR_IND, "" + doc.Ind);
            }
            Dictionary<string, string> metaInfo = this.getFileMetaData(filePath);
            if(metaInfo == null){
                metaInfo = allInformation;
            }else {
                foreach(KeyValuePair<string, string> kv in allInformation ){
                    if(metaInfo.ContainsKey(kv.Key)){
                        metaInfo.Remove(kv.Key);
                    }
                    metaInfo.Add(kv.Key, kv.Value);

                }
            }
            this.setMetaData(filePath, metaInfo);
        }