SlideShare a Scribd company logo
AngularJS & REST Web Services
#OMRS15
Darius Jazayeri
darius@openmrs.org
djazayeri@thoughtworks.com
Download this...
● Download the Postman Chrome app
● https://www.getpostman.com/
● We'll use it shortly
REST
● REST = Representational State Transfer
● the software architectural style of the World Wide Web
● Levels of maturity
– “just add a REST API on top of it”
– Hypermedia as the engine of application state (HATEOAS)
– http://martinfowler.com/articles/richardsonMaturityModel.html
● Using HTTP to interact with the server in a constrained
machine-friendly way
● Constraints allow for scalability via standard web
technologies (stateless, cacheable, layered)
REST concepts
● Resource
– URI that addresses a collection or item in the system
– e.g. http://…/patient or http://…/patient/abc123
● Representation
– Specific state of the application. Based on one of these a client
can change application state
– Typically JSON or XML
● Hyperlinks
– what client can do from a given state
– e.g. {"rel": "next", "uri": "http://.../concept?startIndex=50"}
REST in OpenMRS
● Started in 2011
● Level 2 on the Richardson Maturity Model
– http://martinfowler.com/articles/richardsonMaturityModel.html
● RESTful CRUD access to the OpenMRS
platform data model
● We would like to be REST-first, but we're not
there yet. This is still second-class to our Java
API
REST in OpenMRS
● Documentation on the wiki at “REST Web Services
API For Clients”
– https://wiki.openmrs.org/x/P4IaAQ
– Big refresh coming in the next OpenMRS Platform release
(Swagger!)
● Basic Authentication
● Paging
● Different sized representations (ref, default, full)
– Also, custom representations
REST in OpenMRS: Let's play
● Use the Postman Chrome app (or something
else)
● http://demo.openmrs.org/openmrs/ws/rest/v1/concept
● .../concept?startIndex=50
● .../concept?q=malaria
● .../concept/CIEL:160152
● Add header… Accept: application/xml
● .../location?v=default
REST in OpenMRS: Exercise
● Create an encounter for an existing patient that
records their weight
– You will need to find a patient, look up some other
metadata, and figure out the encounter POST
format
AngularJS
●
https://angularjs.org/ (by Google)
– “HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic
views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting
environment is extraordinarily expressive, readable, and quick to develop.”
● Great framework for building client-side web applications
● Normally, one would build a complete app in AngularJS
– Bahmni
– OpenMRS Ebola Tablet App
● In the OpenMRS Reference Application we embed smaller AngularJS apps in a primarily-
server-side application
– but we're using AngularJS more and more
●
Clone: https://github.com/djazayeri/openmrs-module-angulartutorial
openmrs-core version 1.11.x
modules: appui, uiframework, appframework, uicommons, webservices.rest
AngularJS Concepts
● Directives
– Think of this as an “HTML tag/attribute handler”
– AngularJS code that is applied
– Built-in directives; Also write your own
● Scopes
– The dynamic thing that connects controller to view
– Directives have a $scope (sometimes inherited from a
parent, sometimes isolated)
– $rootScope
AngularJS Concepts
● Two-way data binding
– <input ng-model="myVariable" type="text"/>
– Editing the text box will update $scope.myVariable
– Setting $scope.myVariable will update the text box
● Templates
– with {{ interpolation }}
● Functions in the $scope
– <button ng-click="doSomething()">...</button>
● See example1 in the tutorial module
AngularJS Docs
● Developer Guide
– https://docs.angularjs.org/guide
● API Reference
– https://docs.angularjs.org/api
● More sophisticated: tutorial example2
AngularJS Magic
● Tutorial example3
AngularJS +/- GSP
● OpenMRS Reference Application includes a
non-standard mix of server-side GSP and
client-side AngularJS code
● Filters
– {{ visit.startDate | date }}
● tutorial example4
AngularJS + REST in OpenMRS
● Using raw $http
– Tutorial example5
● Using ngResource
– Tutorial example6
● Services in uicommons module

More Related Content

PPT
Using RESTFUL APIs in ANGULARJS
PDF
Angularjs & REST
PDF
REST in AngularJS
PDF
How to connect AngularJS to servers
PPTX
AngularJS = Browser applications on steroids
PPTX
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
DOCX
multiple views and routing
PPTX
Angular js
Using RESTFUL APIs in ANGULARJS
Angularjs & REST
REST in AngularJS
How to connect AngularJS to servers
AngularJS = Browser applications on steroids
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
multiple views and routing
Angular js

What's hot (19)

PPTX
Designing REST services with Spring MVC
PDF
RESTful Web Services with Spring MVC
PDF
Building RESTful applications using Spring MVC
PPTX
Angular js for beginners
PPTX
Introduction to AngularJS
PDF
Laravel + Restangular Introduction
PPTX
Introduction to Angular JS
PDF
Learn REST in 18 Slides
PDF
Server rendering-talk
PPTX
Angular introduction basic
PDF
Introduction to AJAX In WordPress
PPTX
Single Page Application (SPA) using AngularJS
PPTX
ASP.NET MVC and ajax
PPTX
Angularjs PPT
PPTX
Angular js tutorial slides
PDF
Ch. 11 deploying
PPTX
Ise312 Ec Presentation Jquery
PDF
RoR 101: Session 6
PDF
Spring Mvc Rest
Designing REST services with Spring MVC
RESTful Web Services with Spring MVC
Building RESTful applications using Spring MVC
Angular js for beginners
Introduction to AngularJS
Laravel + Restangular Introduction
Introduction to Angular JS
Learn REST in 18 Slides
Server rendering-talk
Angular introduction basic
Introduction to AJAX In WordPress
Single Page Application (SPA) using AngularJS
ASP.NET MVC and ajax
Angularjs PPT
Angular js tutorial slides
Ch. 11 deploying
Ise312 Ec Presentation Jquery
RoR 101: Session 6
Spring Mvc Rest
Ad

Viewers also liked (20)

PDF
OpenMRS: htmlforms
PPTX
What Is Open M R S
PPTX
OpenMRS Reference Application, Getting Started
PPT
Openmrs Use Examples PPT
PPTX
OpenMRS Concept Management Tutorial
PDF
BE/ ME / MTech / BTech Computer Engineering Project titles IEEE 2014 IEEE 2015
PPT
Darius Open Mrs Examples
PPTX
Health IT and OpenMRS
PPT
OpenMRS Meeting Boston, Introduction
PPTX
FOSS Asia 2016 - OpenMRS networks for networks
PDF
Cover front and back for leadership asg
PPTX
OpenMRS Concept Management Tutorial (addendum)
PPTX
OpenMRS Presentation
PPTX
OpenMRS presentation, part of Google Code-In 2015
PPT
MVP Open Mrs Update 052609
PPT
Seebregts Omrs Oasis Boston May09
PPTX
Open MRS
PPTX
OpenMRS presentation
PPTX
The open mrs hl7query module
PPT
Open Mrs Vision 2
OpenMRS: htmlforms
What Is Open M R S
OpenMRS Reference Application, Getting Started
Openmrs Use Examples PPT
OpenMRS Concept Management Tutorial
BE/ ME / MTech / BTech Computer Engineering Project titles IEEE 2014 IEEE 2015
Darius Open Mrs Examples
Health IT and OpenMRS
OpenMRS Meeting Boston, Introduction
FOSS Asia 2016 - OpenMRS networks for networks
Cover front and back for leadership asg
OpenMRS Concept Management Tutorial (addendum)
OpenMRS Presentation
OpenMRS presentation, part of Google Code-In 2015
MVP Open Mrs Update 052609
Seebregts Omrs Oasis Boston May09
Open MRS
OpenMRS presentation
The open mrs hl7query module
Open Mrs Vision 2
Ad

Similar to AngularJS and REST - #omrs15 tutorial (20)

PPTX
Tutorial_Rest_API_For_Beginners_125.pptx
PPTX
REST API in Agile Testing by Fadly Mahendra
PDF
08 ajax
PDF
Build REST API clients for AngularJS
PDF
Advanced I/O in browser
PDF
Api FUNdamentals #MHA2017
PPTX
Building Self Documenting HTTP APIs with CQRS
PPTX
The future of web development write once, run everywhere with angular.js and ...
PDF
The future of web development write once, run everywhere with angular js an...
PPTX
80068
PDF
2010 code camp rest for the rest of us
PDF
Api fundamentals
PDF
Coders Workshop: API First Mobile Development Featuring Angular and Node
PPTX
RESTful APIs
PPTX
REST API
PPTX
REST Methodologies
PDF
Why should I care about REST?
PDF
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...
Tutorial_Rest_API_For_Beginners_125.pptx
REST API in Agile Testing by Fadly Mahendra
08 ajax
Build REST API clients for AngularJS
Advanced I/O in browser
Api FUNdamentals #MHA2017
Building Self Documenting HTTP APIs with CQRS
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular js an...
80068
2010 code camp rest for the rest of us
Api fundamentals
Coders Workshop: API First Mobile Development Featuring Angular and Node
RESTful APIs
REST API
REST Methodologies
Why should I care about REST?
2013 - Nate Abele: HTTP ALL THE THINGS: Simplificando aplicaciones respetando...

Recently uploaded (20)

PPTX
community services team project 2(4).pptx
PPTX
COMMUNICATION SKILSS IN NURSING PRACTICE
PPTX
AI_in_Pharmaceutical_Technology_Presentation.pptx
PPTX
Galactosemia pathophysiology, clinical features, investigation and treatment ...
PPTX
3. Adherance Complianace.pptx pharmacy pci
PDF
CHAPTER 9 MEETING SAFETY NEEDS FOR OLDER ADULTS.pdf
PPTX
ABG advance Arterial Blood Gases Analysis
PDF
Priorities Critical Care Nursing 7th Edition by Urden Stacy Lough Test Bank.pdf
PPTX
Vaginal Bleeding and Uterine Fibroids p
PPTX
Immunity....(shweta).................pptx
PPTX
Importance of Immediate Response (1).pptx
PDF
NUTRITION THROUGHOUT THE LIFE CYCLE CHILDHOOD -AGEING
PDF
Khaled Sary- Trailblazers of Transformation Middle East's 5 Most Inspiring Le...
PPTX
Pulmonary Circulation PPT final for easy
PPTX
BLS, BCLS Module-A life saving procedure
PPT
Adrenergic drugs (sympathomimetics ).ppt
PPTX
Rheumatic heart diseases with Type 2 Diabetes Mellitus
PPT
Microscope is an instrument that makes an enlarged image of a small object, t...
PPTX
1. Drug Distribution System.pptt b pharmacy
PDF
Dr. Jasvant Modi - Passionate About Philanthropy
community services team project 2(4).pptx
COMMUNICATION SKILSS IN NURSING PRACTICE
AI_in_Pharmaceutical_Technology_Presentation.pptx
Galactosemia pathophysiology, clinical features, investigation and treatment ...
3. Adherance Complianace.pptx pharmacy pci
CHAPTER 9 MEETING SAFETY NEEDS FOR OLDER ADULTS.pdf
ABG advance Arterial Blood Gases Analysis
Priorities Critical Care Nursing 7th Edition by Urden Stacy Lough Test Bank.pdf
Vaginal Bleeding and Uterine Fibroids p
Immunity....(shweta).................pptx
Importance of Immediate Response (1).pptx
NUTRITION THROUGHOUT THE LIFE CYCLE CHILDHOOD -AGEING
Khaled Sary- Trailblazers of Transformation Middle East's 5 Most Inspiring Le...
Pulmonary Circulation PPT final for easy
BLS, BCLS Module-A life saving procedure
Adrenergic drugs (sympathomimetics ).ppt
Rheumatic heart diseases with Type 2 Diabetes Mellitus
Microscope is an instrument that makes an enlarged image of a small object, t...
1. Drug Distribution System.pptt b pharmacy
Dr. Jasvant Modi - Passionate About Philanthropy

AngularJS and REST - #omrs15 tutorial

  • 1. AngularJS & REST Web Services #OMRS15 Darius Jazayeri darius@openmrs.org djazayeri@thoughtworks.com
  • 2. Download this... ● Download the Postman Chrome app ● https://www.getpostman.com/ ● We'll use it shortly
  • 3. REST ● REST = Representational State Transfer ● the software architectural style of the World Wide Web ● Levels of maturity – “just add a REST API on top of it” – Hypermedia as the engine of application state (HATEOAS) – http://martinfowler.com/articles/richardsonMaturityModel.html ● Using HTTP to interact with the server in a constrained machine-friendly way ● Constraints allow for scalability via standard web technologies (stateless, cacheable, layered)
  • 4. REST concepts ● Resource – URI that addresses a collection or item in the system – e.g. http://…/patient or http://…/patient/abc123 ● Representation – Specific state of the application. Based on one of these a client can change application state – Typically JSON or XML ● Hyperlinks – what client can do from a given state – e.g. {"rel": "next", "uri": "http://.../concept?startIndex=50"}
  • 5. REST in OpenMRS ● Started in 2011 ● Level 2 on the Richardson Maturity Model – http://martinfowler.com/articles/richardsonMaturityModel.html ● RESTful CRUD access to the OpenMRS platform data model ● We would like to be REST-first, but we're not there yet. This is still second-class to our Java API
  • 6. REST in OpenMRS ● Documentation on the wiki at “REST Web Services API For Clients” – https://wiki.openmrs.org/x/P4IaAQ – Big refresh coming in the next OpenMRS Platform release (Swagger!) ● Basic Authentication ● Paging ● Different sized representations (ref, default, full) – Also, custom representations
  • 7. REST in OpenMRS: Let's play ● Use the Postman Chrome app (or something else) ● http://demo.openmrs.org/openmrs/ws/rest/v1/concept ● .../concept?startIndex=50 ● .../concept?q=malaria ● .../concept/CIEL:160152 ● Add header… Accept: application/xml ● .../location?v=default
  • 8. REST in OpenMRS: Exercise ● Create an encounter for an existing patient that records their weight – You will need to find a patient, look up some other metadata, and figure out the encounter POST format
  • 9. AngularJS ● https://angularjs.org/ (by Google) – “HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.” ● Great framework for building client-side web applications ● Normally, one would build a complete app in AngularJS – Bahmni – OpenMRS Ebola Tablet App ● In the OpenMRS Reference Application we embed smaller AngularJS apps in a primarily- server-side application – but we're using AngularJS more and more ● Clone: https://github.com/djazayeri/openmrs-module-angulartutorial openmrs-core version 1.11.x modules: appui, uiframework, appframework, uicommons, webservices.rest
  • 10. AngularJS Concepts ● Directives – Think of this as an “HTML tag/attribute handler” – AngularJS code that is applied – Built-in directives; Also write your own ● Scopes – The dynamic thing that connects controller to view – Directives have a $scope (sometimes inherited from a parent, sometimes isolated) – $rootScope
  • 11. AngularJS Concepts ● Two-way data binding – <input ng-model="myVariable" type="text"/> – Editing the text box will update $scope.myVariable – Setting $scope.myVariable will update the text box ● Templates – with {{ interpolation }} ● Functions in the $scope – <button ng-click="doSomething()">...</button> ● See example1 in the tutorial module
  • 12. AngularJS Docs ● Developer Guide – https://docs.angularjs.org/guide ● API Reference – https://docs.angularjs.org/api ● More sophisticated: tutorial example2
  • 14. AngularJS +/- GSP ● OpenMRS Reference Application includes a non-standard mix of server-side GSP and client-side AngularJS code ● Filters – {{ visit.startDate | date }} ● tutorial example4
  • 15. AngularJS + REST in OpenMRS ● Using raw $http – Tutorial example5 ● Using ngResource – Tutorial example6 ● Services in uicommons module