Esempio n. 1
0
        public List <Record> GetRecords(string patientNRIC, long noteID)
        {
            if (AccountBLL.IsTherapist())
            {
                List <Record>  records = recordDAL.RetrieveRecords(noteID, patientNRIC, AccountBLL.GetNRIC());
                Entity.Patient patient = new TherapistBLL().GetPatient(patientNRIC);

                List <Record> result = new List <Record>();
                foreach (Record record in records)
                {
                    if (!patient.hasPermissionsApproved(record))
                    {
                        Record newRecord = new Record();
                        newRecord.id     = record.id;
                        newRecord.title  = record.title;
                        newRecord.type   = record.type;
                        newRecord.status = record.status;
                        newRecord.recordPermissionStatus = record.recordPermissionStatus;
                        result.Add(newRecord);
                    }
                    else
                    {
                        record.permited = true;
                        result.Add(record);
                    }
                }

                logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "View Records of Note", "Action on: " + patientNRIC + " , Note ID: " + noteID + ".");
                return(result);
            }

            return(null);
        }
Esempio n. 2
0
        public bool AddNote(Note note)
        {
            if (AccountBLL.IsTherapist())
            {
                note.therapist.nric = AccountBLL.GetNRIC();
                note.creator.nric   = AccountBLL.GetNRIC();

                // check if every record is valid
                RecordBLL recordBLL = new RecordBLL();

                foreach (Record record in note.records)
                {
                    Entity.Patient patient = GetPatientPermissions(record.patientNRIC);

                    if (patient.approvedTime == null || !recordBLL.VerifyRecord(record))
                    {
                        return(false);
                    }
                }

                therapistDAL.InsertNote(note);
                foreach (Record record in note.records)
                {
                    therapistDAL.InsertNoteRecord(note, record);
                }

                logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "Add Note", "Note ID: " + note.id + ".");
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
 public void RescindPermissions(string patientNRIC)
 {
     if (AccountBLL.IsTherapist() && !patientNRIC.Equals(AccountBLL.GetNRIC()))
     {
         therapistDAL.UpdateRecordTypeRescind(patientNRIC, AccountBLL.GetNRIC());
         logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "Delete Request for Permissions", "Action on: " + patientNRIC + ".");
     }
 }
Esempio n. 4
0
 public void RevokePermissions(string therapistNRIC)
 {
     if (AccountBLL.IsPatient())
     {
         patientDAL.UpdateRequestRevoke(AccountBLL.GetNRIC(), therapistNRIC);
         logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "Revoke Therapist Permissions", "Action on: " + therapistNRIC + ".");
     }
 }
 public Record GetRecord(long recordID)
 {
     if (AccountBLL.IsResearcher())
     {
         return(dataDAL.RetrieveRecord(recordID));
     }
     return(null);
 }
Esempio n. 6
0
 public void ApproveRequest(string therapistNRIC, short permission)
 {
     if (AccountBLL.IsPatient())
     {
         patientDAL.UpdateRequestApprove(AccountBLL.GetNRIC(), therapistNRIC, permission);
         logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "Approve Therapist Permissions", "Action on: " + therapistNRIC + ".");
     }
 }
Esempio n. 7
0
 public void UpdateRequest(string patientNRIC, short permission)
 {
     if (AccountBLL.IsTherapist() && !patientNRIC.Equals(AccountBLL.GetNRIC()))
     {
         therapistDAL.UpdateRecordTypeRequest(patientNRIC, AccountBLL.GetNRIC(), permission);
         logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "Update Request for Permissions", "Action on: " + patientNRIC + ", Permissions: " + permission + ".");
     }
 }
Esempio n. 8
0
 public void UpdateRecordDisable(long recordID)
 {
     if (AccountBLL.IsPatient())
     {
         recordDAL.UpdateRecordDisable(recordID, AccountBLL.GetNRIC());
         logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Update Record Status Disable", "Record ID: " + recordID + ".");
     }
 }
Esempio n. 9
0
        public List <string> GetActions()
        {
            if (AccountBLL.IsAdministrator())
            {
                return(logDAL.RetrieveActions());
            }

            return(null);
        }
Esempio n. 10
0
        private bool HasNote(long noteID)
        {
            if (AccountBLL.IsTherapist())
            {
                return(therapistDAL.DoesNoteExist(noteID, AccountBLL.GetNRIC()));
            }

            return(false);
        }
Esempio n. 11
0
        public List <string> GetCreatorNRICs()
        {
            if (AccountBLL.IsAdministrator())
            {
                return(logDAL.RetrieveCreatorNRICs());
            }

            return(null);
        }
        public List <RecordDiagnosis> GetRecordDiagnoses(long recordID)
        {
            if (AccountBLL.IsResearcher())
            {
                return(dataDAL.RetrieveRecordDiagnoses(recordID));
            }

            return(null);
        }
        public DataTable GetRecordDiagnoses()
        {
            if (AccountBLL.IsResearcher())
            {
                return(dataDAL.RetrieveRecordDiagnoses());
            }

            return(null);
        }
Esempio n. 14
0
        //public void DeleteRecords(string nric)
        //{
        //    if (AccountBLL.IsAdministrator())
        //    {
        //        List<Record> records = recordDAL.RetrieveAssociatedRecords(nric);

        //        foreach (Record record in records)
        //        {
        //            // delete all record diagnosis first
        //            recordDAL.DeleteRecordDiagnosis(record.id);

        //            // delete all permissions
        //            recordDAL.DeleteRecordPermission(record.id);

        //            // delete record
        //            recordDAL.DeleteRecord(record.id);
        //        }
        //    }
        //}

        public bool VerifyRecord(Record record)
        {
            if (AccountBLL.IsTherapist() && recordDAL.RetrieveRecordExists(record.id, record.patientNRIC))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 15
0
        public void AddRecord(Record record)
        {
            if (AccountBLL.IsPatient() && record.patientNRIC.Equals(AccountBLL.GetNRIC()))
            {
                if (record.type.isContent)
                {
                    recordDAL.InsertContent(record, AccountBLL.GetNRIC());
                    logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Insert Record", "Action on: " + record.patientNRIC + ", Record ID: " + record.id + ".");
                }
                else if (!record.type.isContent)
                {
                    record.fileChecksum = record.GetMD5HashFromFile();

                    if (record.IsFileSafe())
                    {
                        recordDAL.InsertFile(record, AccountBLL.GetNRIC());
                    }
                    else
                    {
                        throw new Exception();
                    }

                    logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Insert Record", "Action on: " + record.patientNRIC + ", Record ID: " + record.id + ".");
                }
            }
            else if (AccountBLL.IsTherapist())
            {
                Entity.Patient patient = new TherapistBLL().GetPatientPermissions(record.patientNRIC);

                if (patient.permissionApproved == 0 || ((patient.permissionApproved & record.type.permissionFlag) == 0) ||
                    AccountBLL.GetNRIC().Equals(record.patientNRIC))
                {
                    return;
                }

                if (record.type.isContent)
                {
                    recordDAL.InsertContent(record, AccountBLL.GetNRIC());
                    logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Insert Record", "Action on: " + record.patientNRIC + ", Record ID: " + record.id + ".");
                }
                else if (!record.type.isContent)
                {
                    record.fileChecksum = record.GetMD5HashFromFile();

                    if (record.IsFileSafe())
                    {
                        recordDAL.InsertFile(record, AccountBLL.GetNRIC());
                    }
                    else
                    {
                        throw new Exception();
                    }

                    logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Insert Record", "Action on: " + record.patientNRIC + ", Record ID: " + record.id + ".");
                }
            }
        }
Esempio n. 16
0
        public List <Entity.Therapist> GetTherapists(string term)
        {
            if (AccountBLL.IsTherapist())
            {
                return(therapistDAL.RetrieveTherapists(term, AccountBLL.GetNRIC()));
            }

            return(null);
        }
        public GeneralizedSetting GetGeneralizedSettingFromDb()
        {
            if (AccountBLL.IsResearcher())
            {
                return(dataDAL.RetrieveGeneralizationLevel());
            }

            return(null);
        }
        public DataTable GetPostal()
        {
            if (AccountBLL.IsResearcher())
            {
                return(dataDAL.RetrievePostal());
            }

            return(null);
        }
Esempio n. 19
0
 public void AddPatientDiagnosis(string patientNRIC, string code)
 {
     if (AccountBLL.IsTherapist() &&
         !patientNRIC.Equals(AccountBLL.GetNRIC()) &&
         therapistDAL.RetrievePatientPermission(patientNRIC, AccountBLL.GetNRIC()).approvedTime != null)
     {
         therapistDAL.InsertPatientDiagnosis(patientNRIC, AccountBLL.GetNRIC(), code);
         logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "Add Patient Diagnosis", "Action on: " + patientNRIC + ", Diagnosis Code: " + code + ".");
     }
 }
Esempio n. 20
0
        public List <Record> GetRecords()
        {
            if (AccountBLL.IsPatient())
            {
                List <Record> result = recordDAL.RetrieveRecords(AccountBLL.GetNRIC());
                logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "View Records", "Self.");
                return(result);
            }

            return(null);
        }
Esempio n. 21
0
        public List <Entity.Therapist> GetCurrentTherapists(string term)
        {
            if (AccountBLL.IsPatient())
            {
                List <Entity.Therapist> result = patientDAL.RetrieveCurrentTherapists(term, AccountBLL.GetNRIC());
                logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Current Therapists", "Term: \"" + term + "\".");
                return(result);
            }

            return(null);
        }
Esempio n. 22
0
 public void UpdateRecordTherapistDefault(long recordID, string therapistNRIC)
 {
     if (AccountBLL.IsPatient())
     {
         if (recordDAL.RetrieveRecordOwner(AccountBLL.GetNRIC(), recordID))
         {
             recordDAL.DeleteRecordPermission(recordID, therapistNRIC);
             logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Update Record Status Default", "Record ID: " + recordID + ".");
         }
     }
 }
Esempio n. 23
0
 public void UpdateRecordTherapistDisallow(long recordID, string therapistNRIC)
 {
     if (AccountBLL.IsPatient())
     {
         if (recordDAL.RetrieveRecordOwner(AccountBLL.GetNRIC(), recordID))
         {
             recordDAL.InsertRecordPermissionDisallow(recordID, therapistNRIC);
             logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Update Record Fine Grain Permission Disallow", "Action on: " + therapistNRIC + ", Record ID: " + recordID + ".");
         }
     }
 }
Esempio n. 24
0
        public List <Entity.Therapist> GetCurrentTherapistsFineGrain(string term, long recordID)
        {
            if (AccountBLL.IsPatient())
            {
                List <Entity.Therapist> result = patientDAL.RetrieveCurrentTherapistsFineGrain(term, recordID, AccountBLL.GetNRIC());
                logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "View Record Fine Grain Permissions", "Term: \"" + term + "\", Record ID: " + recordID + ".");
                return(result);
            }

            return(null);
        }
Esempio n. 25
0
        public List <Entity.Therapist> GetDisallowedTherapists(int recordID, string term)
        {
            if (AccountBLL.IsPatient())
            {
                List <Entity.Therapist> result = patientDAL.RetrievePermissionsDisallow(recordID, term, AccountBLL.GetNRIC());
                logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "View Disallowed Therapists", "Term: \"" + term + "\", Record ID: " + recordID + ".");
                return(result);
            }

            return(null);
        }
Esempio n. 26
0
        public Entity.Therapist GetTherapistPermission(string therapistNRIC)
        {
            if (AccountBLL.IsPatient())
            {
                Entity.Therapist result = patientDAL.RetrieveTherapistPermission(therapistNRIC, AccountBLL.GetNRIC());
                logPermissionBLL.LogEvent(AccountBLL.GetNRIC(), "View Therapist Permissions", "Action on: " + therapistNRIC + ".");
                return(result);
            }

            return(null);
        }
Esempio n. 27
0
        public Entity.Patient GetPatientPermissions(string patientNRIC)
        {
            if (AccountBLL.IsTherapist() && !patientNRIC.Equals(AccountBLL.GetNRIC()))
            {
                Entity.Patient result = therapistDAL.RetrievePatientPermission(patientNRIC, AccountBLL.GetNRIC());
                logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Patients Permission", "Action on: " + patientNRIC + ".");
                return(result);
            }

            return(null);
        }
        public List <PatientDiagnosis> GetPatientDiagnoses(string id)
        {
            if (AccountBLL.IsResearcher())
            {
                List <PatientDiagnosis> result = dataDAL.RetrievePatientDiagnoses(id);
                logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Patient Diagnoses", "View Patient Diagnoses");
                return(result);
            }

            return(null);
        }
Esempio n. 29
0
        public List <PatientDiagnosis> GetDiagnoses()
        {
            if (AccountBLL.IsPatient())
            {
                List <PatientDiagnosis> result = patientDAL.RetrievePatientDiagnoses(AccountBLL.GetNRIC());
                logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Diagnoses", "Self.");

                return(result);
            }

            return(null);
        }
Esempio n. 30
0
        public List <PatientDiagnosis> GetPatientDiagnoses(string patientNRIC, long id)
        {
            if (AccountBLL.IsTherapist() && !patientNRIC.Equals(AccountBLL.GetNRIC()) &&
                therapistDAL.RetrievePatientPermission(patientNRIC, AccountBLL.GetNRIC()).approvedTime != null)
            {
                List <PatientDiagnosis> result = therapistDAL.RetrievePatientDiagnoses(patientNRIC, AccountBLL.GetNRIC());
                logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Patient Diagnoses", "Action on: " + patientNRIC + ".");
                return(result);
            }

            return(null);
        }