Skip to content

Instantly share code, notes, and snippets.

@NSAmit
NSAmit / BuildNumber.sh
Created September 5, 2018 00:43
Code to increment build number automatically
# Assume that I have MyApp as a repository and my project root folder is also MyApp.
echo "Lets update the build number for featire releases"
echo "Creating temp folder as ~/Documents/TempCadenceIosBuildIncrement/"
mkdir ~/Documents/TempIosBuildIncrement/
cd ~/Documents/TempIosBuildIncrement/
echo "Cloning Repo of master branch....."
git clone https://gitlab.com/MyApp.git # clone your master branch here.
echo "Clonned successfully. Updating build number now using PlistBuddy"
cd MyApp/ # get into the project directory.
@NSAmit
NSAmit / HealthRecordAccess.swift
Last active March 8, 2019 01:16
Code to request authorization for Clinical Records
// Make sure you import HealthKit
// Get the HKHealthStore reference. Must be single reference in your app.
let healthStore = HKHealthStore()
// Create required Record Type's equivalent HKClinicalType using clinicalType func of HKObjectType
guard let allergyRecord = HKObjectType.clinicalType(forIdentifier: .allergyRecord),
let medicationRecord = HKObjectType.clinicalType(forIdentifier: .medicationRecord),
let conditionRecord = HKObjectType.clinicalType(forIdentifier: .conditionRecord),
func getRecordUsingPredicateForAllergyType(recordReadCompletionHandler:@escaping ([HKClinicalRecord]?) -> Void) {
guard let healthRecordAllergyType = HKObjectType.clinicalType(forIdentifier: .allergyRecord) else {
fatalError("*** Unable to create the Allergy type ***")
}
let healthRecordPredicate = HKQuery.predicateForClinicalRecords(withFHIRResourceType: .allergyIntolerance)
func getRecordForType(type: HKClinicalTypeIdentifier, recordReadCompletionHandler:@escaping ([HKClinicalRecord]?) -> Void) {
guard let healthRecordType = HKObjectType.clinicalType(forIdentifier: type) else {
fatalError("*** Unable to create the record type ***")
}
let healthRecordQuery = HKSampleQuery(sampleType: healthRecordType, predicate: nil, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, samples, error) in
guard let actualSamples = samples else {
// MARK: Allergy
struct Reaction:Codable {
let onset:String?
let manifestation:[[String: String]]
let severity:String
}
struct Allergy: Codable {
let id: String
// MARK: Condition
struct Condition:Codable {
let id: String
let resourceType:String
let asserter:Person
let category:[String: [[String: String]]]
let clinicalStatus: String
let code: CodeableConcept
// MARK: Immunization
struct Immunization:Codable {
let id: String
let resourceType:String
let vaccineCode:CodeableConcept
let encounter:[String: String]
let requester:[String: String]
let date: String
// MARK: LabResult
struct ReferenceRange:Codable {
let low:ValueQuantity
let high:ValueQuantity
let text:String
}
struct ValueQuantity:Codable {
// MARK: Medication
struct DosageInstruction: Codable {
let text:String?
let timing:[String:[String:String?]?]?
}
struct Medication:Codable {
let dateWritten:String
let status: String
// MARK: Procedure
struct Procedure:Codable {
let id: String
let resourceType:String
let code:CodeableConcept
let status:String
let encounter:[String: String]
let performedDateTime:String