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); }
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); }
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 + "."); } }
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 + "."); } }
public List <Entity.Therapist> GetTherapists(string term) { if (AccountBLL.IsTherapist()) { return(therapistDAL.RetrieveTherapists(term, AccountBLL.GetNRIC())); } return(null); }
private bool HasNote(long noteID) { if (AccountBLL.IsTherapist()) { return(therapistDAL.DoesNoteExist(noteID, AccountBLL.GetNRIC())); } return(false); }
//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); }
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 + "."); } } }
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 + "."); } }
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 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); }
public void AddRecordDiagnosis(string patientNRIC, long recordID, string code) { if (AccountBLL.IsTherapist()) { Record record = recordDAL.RetrieveRecord(recordID, AccountBLL.GetNRIC()); Entity.Patient patient = new TherapistBLL().GetPatient(record.patientNRIC); if (record.patientNRIC.Equals(patientNRIC) && patient.hasPermissionsApproved(record)) { logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "Insert Record Diagnoses", "Action on: " + patientNRIC + ", Record ID: " + recordID + ", Diagnosis Code: " + code + "."); recordDAL.InsertRecordDiagnosis(AccountBLL.GetNRIC(), recordID, code); } } }
public Note GetNote(long noteID) { if (AccountBLL.IsTherapist()) { Note note = therapistDAL.RetrieveNote(noteID, AccountBLL.GetNRIC()); if (note.patient.approvedTime != null) { note.patient = therapistDAL.RetrievePatientInformation(note.patient.nric, AccountBLL.GetNRIC()); } logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Note", "Note ID: " + noteID + "."); return(note); } return(null); }
public bool AcceptEmergencyPatient(string tokenID) { if (AccountBLL.IsTherapist()) { string patientNRIC = therapistDAL.RetrieveEmergencyPatient(tokenID, AccountBLL.GetNRIC()); if (string.IsNullOrEmpty(patientNRIC) || string.Equals(patientNRIC, AccountBLL.GetNRIC())) { return(false); } therapistDAL.AcceptEmergencyTherapist(patientNRIC, AccountBLL.GetNRIC()); return(true); } return(false); }
public List <RecordDiagnosis> GetRecordDiagnoses(long recordID) { if (AccountBLL.IsPatient()) { return(recordDAL.RetrieveRecordDiagnoses(recordID, AccountBLL.GetNRIC())); } else if (AccountBLL.IsTherapist()) { Record record = recordDAL.RetrieveRecord(recordID, AccountBLL.GetNRIC()); Entity.Patient patient = new TherapistBLL().GetPatient(record.patientNRIC); if (patient.hasPermissionsApproved(record)) { List <RecordDiagnosis> result = recordDAL.RetrieveRecordDiagnoses(recordID, record.patientNRIC, AccountBLL.GetNRIC()); logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "View Record Diagnoses", "Record ID: " + recordID + "."); return(result); } } return(null); }
public List <Entity.Patient> GetCurrentPatients(string term) { if (AccountBLL.IsTherapist()) { List <Entity.Patient> patients = therapistDAL.RetrieveCurrentPatients(term, AccountBLL.GetNRIC()); foreach (Entity.Patient patient in patients) { if (patient.approvedTime == null) { patient.firstName = string.Empty; patient.lastName = string.Empty; } } logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Current Patients", "Term: \"" + term + "\"."); return(patients); } return(null); }
public void SendNote(long noteID, HashSet <string> therapistsNRIC) { if (AccountBLL.IsTherapist() && HasNote(noteID)) { Note note = therapistDAL.RetrieveNote(noteID, AccountBLL.GetNRIC()); note.records = new RecordBLL().GetRecords(note.patient.nric, note.id); foreach (string therapistNRIC in therapistsNRIC) { note.therapist.nric = therapistNRIC; therapistDAL.InsertNote(note); foreach (Record record in note.records) { therapistDAL.InsertNoteRecord(note, record); } } logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "Send Note", "Sent to: " + therapistsNRIC + ", Note ID: " + note.id + "."); } }
public List <Diagnosis> GetDiagnoses(string term, string patientNRIC, List <RecordDiagnosis> recordDiagnoses) { if (AccountBLL.IsTherapist() && !patientNRIC.Equals(AccountBLL.GetNRIC()) && therapistDAL.RetrievePatientPermission(patientNRIC, AccountBLL.GetNRIC()).approvedTime != null) { List <Diagnosis> patientDiagnoses = therapistDAL.RetrievePatientCurrentDiagnoses(patientNRIC, AccountBLL.GetNRIC(), term); List <Diagnosis> result = new List <Diagnosis>(); foreach (Diagnosis diagnosis in patientDiagnoses) { if (!recordDiagnoses.Any(x => x.diagnosis.code.Equals(diagnosis.code))) { result.Add(diagnosis); } } return(result); } return(null); }
public List <Note> GetNotes(string term) { if (AccountBLL.IsTherapist()) { List <Note> notes = therapistDAL.RetrieveNotes(term, AccountBLL.GetNRIC()); foreach (Note note in notes) { if (note.patient.approvedTime == null) { note.patient.firstName = string.Empty; note.patient.lastName = string.Empty; } } logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Notes", "Term: \"" + term + "\"."); return(notes); } return(null); }
public Record GetRecord(long recordID) { if (AccountBLL.IsPatient()) { return(recordDAL.RetrieveRecord(AccountBLL.GetNRIC(), recordID)); } else if (AccountBLL.IsTherapist()) { Record record = recordDAL.RetrieveRecord(recordID, AccountBLL.GetNRIC()); Entity.Patient patient = new TherapistBLL().GetPatient(record.patientNRIC); if (patient.hasPermissionsApproved(record)) { record.permited = true; logRecordBLL.LogEvent(AccountBLL.GetNRIC(), "View Record", "Record ID: " + recordID + "."); return(record); } } return(null); }
public List <Entity.Patient> GetUnrequestedPatients(string term) { if (AccountBLL.IsTherapist()) { List <Entity.Patient> accountsAllPatients = therapistDAL.RetrieveAllPatients(term); List <Entity.Patient> accountsCurrentPatients = therapistDAL.RetrieveCurrentPatientsDelimited(AccountBLL.GetNRIC()); // remove current user accountsAllPatients.RemoveAll(x => x.nric.Equals(AccountBLL.GetNRIC(), StringComparison.InvariantCultureIgnoreCase)); foreach (Entity.Patient patients in accountsAllPatients) { if (!accountsCurrentPatients.Any(x => x.nric.Equals(patients.nric))) { patients.acceptNewRequest = true; } } logAccountBLL.LogEvent(AccountBLL.GetNRIC(), "View Unrequested Patients", "Term: \"" + term + "\"."); return(accountsAllPatients); } return(null); }