<commit_before><commit_msg>Updated blood pressure measurement list to be sorted.<commit_after>//
//  Config.swift
//  BPApp
//
//  Created by MiningMarsh on 9/26/17.
//  Copyright © 2017 BlackstoneBuilds. All rights reserved.
//

import Foundation
import os.log

public class Config {
    
    // Where to save and load patient data.
    static let DocumentsDirectory = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!
    static let PatientStore = DocumentsDirectory.appendingPathComponent("patients")
    
    // The list of patients we save.
    static public var patients: [Patient] {
        get {
            
            // Lock object so that we don't get while someone is setting.
            objc_sync_enter(self)
            defer { objc_sync_exit(self) }
            
            if let restored = NSKeyedUnarchiver.unarchiveObject(withFile: Config.PatientStore.path) as? [Patient] {
                
                os_log("Patients restored.", log: OSLog.default, type: .debug)
                return restored
                
            } else {
                os_log("Failed to restore patients.", log: OSLog.default, type: .debug)
                return []
            }
        }
        
        set(newPatients) {
            
            // Lock object so that we don't corrupt another lock operation.
            objc_sync_enter(self)
            defer { objc_sync_exit(self) }
            
            let isSuccessfulSave = NSKeyedArchiver.archiveRootObject(
                newPatients,
                toFile: Config.PatientStore.path
            )
            
            if isSuccessfulSave {
                
                os_log("Patients persisted.", log: OSLog.default, type: .debug)
            } else {
                
                os_log("Failed to persist patients...", log: OSLog.default, type: .error)
            }
        }
    }
    
    
}

{'fraction_non_alphanumeric': 0.08411703239289446, 'fraction_numerical': 0.004702194357366771, 'mean_word_length': 1.5499334221038614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2454418', 'n_tokens_mistral': 520, 'n_tokens_neox': 484, 'n_words': 135}