the indivo x ios framework
DESCRIPTION
A walkthrough of building new apps on top of the Indivo iOS framework, as well as integrating it with existing apps to cloud-enable them.By Pascal Pfiffner, MD Ph.D., Children's Hospital Informatics ProgramTRANSCRIPT
![Page 1: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/1.jpg)
Indivo iOS
framework
![Page 2: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/2.jpg)
Goals
• Drop-in to existing Cocoa projects
• Provide a low entry barrier into PHR
• Make Indivo a viable choice for App developers who want to move their users’ data into the cloud
![Page 3: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/3.jpg)
The framework
• Handles authentication (OAuth)
• Provides Indivo objects (automatic XML handling)
• Knows where an object comes from (REST paths)
• Provides messaging functionality
![Page 4: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/4.jpg)
Handling OAuth
• Class INServerCall to encapsulate requests
• Uses MPOAuth, an OSS OAuth framework for iOS, transparently
‣ OAuth is handled for you
![Page 5: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/5.jpg)
From Schema to Cocoa
• The developer should not have to deal with XML serialization/deserialization
‣ Provide classes for all Indivo document types
• We have to write Objective-C classes for all types
‣ A generator creates Cocoa classes from Indivo’s XSD and SDMJ schemas
![Page 6: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/6.jpg)
Self-aware objects
• Document objects know their record
• Records know their server
• Framework knows the server actions
‣ REST methods can be inferred for all tasks
![Page 7: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/7.jpg)
Abstract logic into Cocoa objects
iOS framework
Server Record
addDocumentOfClass:
fetchReportsOfClass:
selectRecord:
Docspush:
replace:
archive:
...
![Page 8: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/8.jpg)
Setup
App Flow
#define kIndivoFrameworkServerURL @“http://10.17.20.127:8000” #define kIndivoFrameworkUIServerURL @“http://10.17.20.127:8001” #define kIndivoFrameworkAppId @“[email protected]” #define kIndivoFrameworkConsumerKey @“nkd8cg02mgo34sntkao9” #define kIndivoFrameworkConsumerSecret @“1acgk9804wkmraoceu02”
server = [IndivoServer serverWithDelegate:self];
![Page 9: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/9.jpg)
Logging in
App Flow
[server selectRecord:^{ }];
server.activeRecord
![Page 10: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/10.jpg)
Adding a medication
App Flow
Medication *med = [record addDocument:Medication];
[med push:^{ }];
med.drugName = [INCodedValue new];
med.drugName.title = @“Tylenol”;
med.drugName.system ...
![Page 11: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/11.jpg)
Sending a message
App Flow
[med.activeRecord sendMessage:@“New medication added” withBody:@“See medlist app” ofType:INMessageTypePlaintext severity:INMessageSeverityMedium attachments:nil callback:^{ }];
![Page 12: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/12.jpg)
Integrating Indivo Into Existing Apps
![Page 13: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/13.jpg)
Growth Charts App
![Page 14: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/14.jpg)
Data Models
Growth Charts App
CHPatientSource selectPatient:^{ }
CHPatient ageAtDate: measurementSetsContainingDataTypes:
CHMeasurementSet date CHMeasurement value CHMeasurement value CHMeasurement value
![Page 15: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/15.jpg)
Local Data Source
Growth Charts App
• Override selectPatient:
• Instantiate a CHPatient
• Read CSV data as measurement sets
![Page 16: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/16.jpg)
Indivo Data Source
Growth Charts App
• Call Indivo’s selectRecord: method
• Within the callback block:
• Fetch patient demographics
• Create CHPatient with record demographics
• Fetch patient’s vitals
• Convert Indivo vitals into measurement sets
![Page 17: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/17.jpg)
Indivo-Enabled (read-only)
Growth Charts App
• 2 lines + app setup file to setup Indivo server instance
• 9 lines to convert IndivoRecord to CHPatient
• 21 lines to convert Indivo vitals into CHMeasurementSet
![Page 18: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/18.jpg)
Documentation
• Take a look at README.md
• Checkout the sample medication app
• Technical documentation available online:
http://docs.indivohealth.org/projects/indivo-x-ios-framework/en/latest/
![Page 19: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/19.jpg)
Playing with Medications
![Page 20: the Indivo X iOS Framework](https://reader033.vdocument.in/reader033/viewer/2022060118/558c8eb1d8b42a0b268b4629/html5/thumbnails/20.jpg)
Version 2.0 α
Available with the other Indivo sources from:
https://github.com/chb/IndivoFramework-ios
Checkout branch dev_two (tag hackathon_2012)