lifen_fhir 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +9 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +74 -0
  8. data/License.txt +22 -0
  9. data/README.md +131 -0
  10. data/lib/lifen_fhir/app_authenticated_client.rb +38 -0
  11. data/lib/lifen_fhir/attachment.rb +26 -0
  12. data/lib/lifen_fhir/base.rb +7 -0
  13. data/lib/lifen_fhir/binary.rb +29 -0
  14. data/lib/lifen_fhir/category.rb +26 -0
  15. data/lib/lifen_fhir/channel.rb +31 -0
  16. data/lib/lifen_fhir/client.rb +107 -0
  17. data/lib/lifen_fhir/communication_request.rb +67 -0
  18. data/lib/lifen_fhir/configuration.rb +22 -0
  19. data/lib/lifen_fhir/content_string.rb +15 -0
  20. data/lib/lifen_fhir/error.rb +27 -0
  21. data/lib/lifen_fhir/medium.rb +15 -0
  22. data/lib/lifen_fhir/patient.rb +27 -0
  23. data/lib/lifen_fhir/practitioner.rb +97 -0
  24. data/lib/lifen_fhir/user_authenticated_client.rb +39 -0
  25. data/lib/lifen_fhir/version.rb +3 -0
  26. data/lib/lifen_fhir.rb +29 -0
  27. data/lifen_fhir.gemspec +30 -0
  28. data/spec/binary_spec.rb +29 -0
  29. data/spec/cassettes/binary/download/invalid.yml +65 -0
  30. data/spec/cassettes/binary/download/valid.yml +1320 -0
  31. data/spec/cassettes/communication_request/send/invalid_medium.yml +69 -0
  32. data/spec/cassettes/communication_request/send/valid_attributes.yml +75 -0
  33. data/spec/cassettes/communication_request/send/valid_attributes_binary.yml +74 -0
  34. data/spec/cassettes/practitionner/create_channel/address/old_valid_attributes.yml +71 -0
  35. data/spec/cassettes/practitionner/create_channel/address/valid_attributes.yml +71 -0
  36. data/spec/cassettes/practitionner/create_channel/telecom/valid_attributes.yml +70 -0
  37. data/spec/cassettes/practitionner/find_by_rpps/existing_rpps.yml +125 -0
  38. data/spec/cassettes/practitionner/find_by_rpps/missing_line_attribute.yml +122 -0
  39. data/spec/cassettes/practitionner/find_by_rpps/wrong_rpps.yml +68 -0
  40. data/spec/category_spec.rb +21 -0
  41. data/spec/communication_request_spec.rb +64 -0
  42. data/spec/practitionner_spec.rb +76 -0
  43. data/spec/spec_helper.rb +24 -0
  44. data/spec/support/master_plan.pdf +0 -0
  45. metadata +232 -0
@@ -0,0 +1,74 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/CommunicationRequest
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"CommunicationRequest","sender":[{"reference":"Practitioner/valid-sender-uuid"}],"recipient":[{"reference":"Practitioner/valid-recipient-uuid-1"},{"reference":"Practitioner/valid-recipient-uuid-2"}],"contained":[{"id":"patient","resourceType":"Patient","name":[{"family":["Dupond"],"given":["Jean"]}],"birthDate":"2000-01-01"}],"medium":[{"coding":[{"id":"valid-medium-uuid-1"}]},{"coding":[{"id":"valid-medium-uuid-2"}]}],"category":[{"coding":[{"system":"http://honestica.com/fhir/communication/category","code":"MEDICAL_REPORT"}]}],"payload":[{"contentReference":{"reference":"Binary/valid-binary-uuid"}}],"subject":[{"reference":"patient"}]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.11.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Content-Type:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - 29ca77f2d9d0e498
31
+ X-B3-Traceid:
32
+ - 29ca77f2d9d0e498
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ Cache-Control:
38
+ - no-cache, no-store, max-age=0, must-revalidate
39
+ Pragma:
40
+ - no-cache
41
+ Expires:
42
+ - '0'
43
+ X-Powered-By:
44
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
45
+ Location:
46
+ - http://ho2-808.story.lifen.fr/fhir/OperationOutcome/08d91f72-c27d-4674-aa38-9c18ed0a221b
47
+ Content-Type:
48
+ - application/json+fhir;charset=UTF-8
49
+ Transfer-Encoding:
50
+ - chunked
51
+ Date:
52
+ - Wed, 26 Apr 2017 16:54:05 GMT
53
+ Access-Control-Allow-Credentials:
54
+ - 'true'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |-
58
+ {
59
+ "resourceType": "OperationOutcome",
60
+ "id": "08d91f72-c27d-4674-aa38-9c18ed0a221b",
61
+ "issue": [
62
+ {
63
+ "severity": "information",
64
+ "diagnostics": "CommunicationRequest accepted"
65
+ },
66
+ {
67
+ "severity": "information",
68
+ "diagnostics": "CommunicationRequest accepted"
69
+ }
70
+ ]
71
+ }
72
+ http_version:
73
+ recorded_at: Wed, 26 Apr 2017 16:53:24 GMT
74
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/11e5c85e-9bc0-4c6e-9b29-deb9993a92c0/$add-address
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"Practitioner","address":{"line":["Honestica","39 rue
9
+ d''Aboukir"],"city":"Paris","postalCode":"75002","country":"France"}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.11.0
13
+ Authorization:
14
+ - Bearer valid_application_access_token
15
+ Accept:
16
+ - application/json
17
+ Content-Type:
18
+ - application/json
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ Server:
27
+ - Apache-Coyote/1.1
28
+ X-B3-Sampled:
29
+ - '1'
30
+ X-B3-Spanid:
31
+ - 1471c2eb1e86756b
32
+ X-B3-Traceid:
33
+ - 1471c2eb1e86756b
34
+ X-Content-Type-Options:
35
+ - nosniff
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ Cache-Control:
39
+ - no-cache, no-store, max-age=0, must-revalidate
40
+ Pragma:
41
+ - no-cache
42
+ Expires:
43
+ - '0'
44
+ X-Powered-By:
45
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
46
+ Content-Type:
47
+ - application/json+fhir;charset=UTF-8
48
+ Transfer-Encoding:
49
+ - chunked
50
+ Date:
51
+ - Fri, 19 May 2017 15:07:35 GMT
52
+ Connection:
53
+ - close
54
+ Access-Control-Allow-Credentials:
55
+ - 'true'
56
+ body:
57
+ encoding: UTF-8
58
+ string: |-
59
+ {
60
+ "resourceType": "OperationOutcome",
61
+ "issue": [
62
+ {
63
+ "id": "11e73ca4-e3d4-8c5f-b5c5-0242ac110002",
64
+ "severity": "information",
65
+ "diagnostics": "Address created."
66
+ }
67
+ ]
68
+ }
69
+ http_version:
70
+ recorded_at: Fri, 19 May 2017 15:07:06 GMT
71
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/11e5c85e-9bc0-4c6e-9b29-deb9993a92c0/$add-address
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"Practitioner","address":{"line":["Honestica","39 rue
9
+ d''Aboukir"],"city":"Paris","postalCode":"75002","country":"France"}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.11.0
13
+ Authorization:
14
+ - Bearer valid_application_access_token
15
+ Accept:
16
+ - application/json
17
+ Content-Type:
18
+ - application/json
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ Server:
27
+ - Apache-Coyote/1.1
28
+ X-B3-Sampled:
29
+ - '1'
30
+ X-B3-Spanid:
31
+ - 6bdba43c90ff2827
32
+ X-B3-Traceid:
33
+ - 6bdba43c90ff2827
34
+ X-Content-Type-Options:
35
+ - nosniff
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ Cache-Control:
39
+ - no-cache, no-store, max-age=0, must-revalidate
40
+ Pragma:
41
+ - no-cache
42
+ Expires:
43
+ - '0'
44
+ X-Powered-By:
45
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
46
+ Content-Type:
47
+ - application/json+fhir;charset=UTF-8
48
+ Transfer-Encoding:
49
+ - chunked
50
+ Date:
51
+ - Fri, 19 May 2017 14:59:33 GMT
52
+ Connection:
53
+ - close
54
+ Access-Control-Allow-Credentials:
55
+ - 'true'
56
+ body:
57
+ encoding: UTF-8
58
+ string: |-
59
+ {
60
+ "resourceType": "OperationOutcome",
61
+ "issue": [
62
+ {
63
+ "id": "11e73ca3-c4b2-fe69-b5c5-0242ac110002",
64
+ "severity": "information",
65
+ "diagnostics": "Address created."
66
+ }
67
+ ]
68
+ }
69
+ http_version:
70
+ recorded_at: Fri, 19 May 2017 14:59:03 GMT
71
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,70 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/11e5c85e-9bc0-4c6e-9b29-deb9993a92c0/$add-telecom
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"Practitioner","telecom":{"system":"fax","value":"+33102030405"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.11.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Content-Type:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - b68d00cd53303e01
31
+ X-B3-Traceid:
32
+ - b68d00cd53303e01
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ Cache-Control:
38
+ - no-cache, no-store, max-age=0, must-revalidate
39
+ Pragma:
40
+ - no-cache
41
+ Expires:
42
+ - '0'
43
+ X-Powered-By:
44
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
45
+ Content-Type:
46
+ - application/json+fhir;charset=UTF-8
47
+ Transfer-Encoding:
48
+ - chunked
49
+ Date:
50
+ - Fri, 19 May 2017 14:59:34 GMT
51
+ Connection:
52
+ - close
53
+ Access-Control-Allow-Credentials:
54
+ - 'true'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |-
58
+ {
59
+ "resourceType": "OperationOutcome",
60
+ "issue": [
61
+ {
62
+ "id": "11e73ca3-c56a-8e9b-b5c5-0242ac110002",
63
+ "severity": "information",
64
+ "diagnostics": "Fax created."
65
+ }
66
+ ]
67
+ }
68
+ http_version:
69
+ recorded_at: Fri, 19 May 2017 14:59:04 GMT
70
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,125 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/?identifier=810004085790
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.11.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-B3-Sampled:
26
+ - '1'
27
+ X-B3-Spanid:
28
+ - 6786028277bfd4e7
29
+ X-B3-Traceid:
30
+ - 6786028277bfd4e7
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Cache-Control:
36
+ - no-cache, no-store, max-age=0, must-revalidate
37
+ Pragma:
38
+ - no-cache
39
+ Expires:
40
+ - '0'
41
+ X-Powered-By:
42
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
43
+ Last-Modified:
44
+ - Fri, 19 May 2017 14:48:42 GMT
45
+ Content-Type:
46
+ - application/json+fhir;charset=UTF-8
47
+ Transfer-Encoding:
48
+ - chunked
49
+ Date:
50
+ - Fri, 19 May 2017 14:48:41 GMT
51
+ Connection:
52
+ - close
53
+ Access-Control-Allow-Credentials:
54
+ - 'true'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |-
58
+ {
59
+ "resourceType": "Bundle",
60
+ "id": "0e708d29-f29f-4378-a874-81c7a8579692",
61
+ "meta": {
62
+ "lastUpdated": "2017-05-19T14:48:42.087+00:00"
63
+ },
64
+ "type": "searchset",
65
+ "total": 1,
66
+ "link": [
67
+ {
68
+ "relation": "self",
69
+ "url": "http://rc.lifen.fr/fhir/Practitioner/?identifier=810004085790"
70
+ }
71
+ ],
72
+ "entry": [
73
+ {
74
+ "fullUrl": "http://rc.lifen.fr/fhir/Practitioner/11e5c86b-e4ba-eee4-9b29-deb9993a92c0",
75
+ "resource": {
76
+ "resourceType": "Practitioner",
77
+ "id": "11e5c86b-e4ba-eee4-9b29-deb9993a92c0",
78
+ "identifier": [
79
+ {
80
+ "system": "http://honestica.com/fhir/identifier/fr/asip",
81
+ "value": "810004085790"
82
+ }
83
+ ],
84
+ "name": [
85
+ {
86
+ "text": "WILLIAM ECLANCHER",
87
+ "family": "ECLANCHER",
88
+ "given": [
89
+ "WILLIAM"
90
+ ],
91
+ "prefix": [
92
+ "DR"
93
+ ]
94
+ }
95
+ ],
96
+ "telecom": [
97
+ {
98
+ "id": "11e61052-91cf-185b-8234-6accfa9deeee",
99
+ "system": "email",
100
+ "value": "William.ECLANCHER@medical75.apicrypt.org"
101
+ },
102
+ {
103
+ "id": "11e62721-8caa-da09-b2d8-6accfa9deeee",
104
+ "system": "email",
105
+ "value": "william.eclancher@medecin.mssante.fr"
106
+ }
107
+ ],
108
+ "address": [
109
+ {
110
+ "id": "11e5c86e-adb9-5453-9b29-deb9993a92c0",
111
+ "line": [
112
+ "11 RUE CHARLES TELLIER"
113
+ ],
114
+ "city": "Paris",
115
+ "postalCode": "75016",
116
+ "country": "FRANCE"
117
+ }
118
+ ]
119
+ }
120
+ }
121
+ ]
122
+ }
123
+ http_version:
124
+ recorded_at: Fri, 19 May 2017 14:48:11 GMT
125
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,122 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/?identifier=810004085790
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.11.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-B3-Sampled:
26
+ - '1'
27
+ X-B3-Spanid:
28
+ - b3724b375a363665
29
+ X-B3-Traceid:
30
+ - b3724b375a363665
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Cache-Control:
36
+ - no-cache, no-store, max-age=0, must-revalidate
37
+ Pragma:
38
+ - no-cache
39
+ Expires:
40
+ - '0'
41
+ X-Powered-By:
42
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
43
+ Last-Modified:
44
+ - Fri, 19 May 2017 14:48:42 GMT
45
+ Content-Type:
46
+ - application/json+fhir;charset=UTF-8
47
+ Transfer-Encoding:
48
+ - chunked
49
+ Date:
50
+ - Fri, 19 May 2017 14:48:41 GMT
51
+ Connection:
52
+ - close
53
+ Access-Control-Allow-Credentials:
54
+ - 'true'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |-
58
+ {
59
+ "resourceType": "Bundle",
60
+ "id": "b7a03b48-612d-44aa-bacd-05f4f05b8d89",
61
+ "meta": {
62
+ "lastUpdated": "2017-05-19T14:48:42.500+00:00"
63
+ },
64
+ "type": "searchset",
65
+ "total": 1,
66
+ "link": [
67
+ {
68
+ "relation": "self",
69
+ "url": "http://rc.lifen.fr/fhir/Practitioner/?identifier=810004085790"
70
+ }
71
+ ],
72
+ "entry": [
73
+ {
74
+ "fullUrl": "http://rc.lifen.fr/fhir/Practitioner/11e5c86b-e4ba-eee4-9b29-deb9993a92c0",
75
+ "resource": {
76
+ "resourceType": "Practitioner",
77
+ "id": "11e5c86b-e4ba-eee4-9b29-deb9993a92c0",
78
+ "identifier": [
79
+ {
80
+ "system": "http://honestica.com/fhir/identifier/fr/asip",
81
+ "value": "810004085790"
82
+ }
83
+ ],
84
+ "name": [
85
+ {
86
+ "text": "WILLIAM ECLANCHER",
87
+ "family": "ECLANCHER",
88
+ "given": [
89
+ "WILLIAM"
90
+ ],
91
+ "prefix": [
92
+ "DR"
93
+ ]
94
+ }
95
+ ],
96
+ "telecom": [
97
+ {
98
+ "id": "11e61052-91cf-185b-8234-6accfa9deeee",
99
+ "system": "email",
100
+ "value": "William.ECLANCHER@medical75.apicrypt.org"
101
+ },
102
+ {
103
+ "id": "11e62721-8caa-da09-b2d8-6accfa9deeee",
104
+ "system": "email",
105
+ "value": "william.eclancher@medecin.mssante.fr"
106
+ }
107
+ ],
108
+ "address": [
109
+ {
110
+ "id": "11e5c86e-adb9-5453-9b29-deb9993a92c0",
111
+ "city": "Paris",
112
+ "postalCode": "75016",
113
+ "country": "FRANCE"
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ ]
119
+ }
120
+ http_version:
121
+ recorded_at: Fri, 19 May 2017 14:48:12 GMT
122
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,68 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/?identifier=8888888888
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.11.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-B3-Sampled:
26
+ - '1'
27
+ X-B3-Spanid:
28
+ - a02774f0dfc94452
29
+ X-B3-Traceid:
30
+ - a02774f0dfc94452
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Cache-Control:
36
+ - no-cache, no-store, max-age=0, must-revalidate
37
+ Pragma:
38
+ - no-cache
39
+ Expires:
40
+ - '0'
41
+ X-Powered-By:
42
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
43
+ Content-Type:
44
+ - application/json+fhir;charset=UTF-8
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Date:
48
+ - Fri, 19 May 2017 15:35:06 GMT
49
+ Connection:
50
+ - close
51
+ Access-Control-Allow-Credentials:
52
+ - 'true'
53
+ body:
54
+ encoding: UTF-8
55
+ string: |-
56
+ {
57
+ "resourceType": "OperationOutcome",
58
+ "issue": [
59
+ {
60
+ "severity": "error",
61
+ "code": "processing",
62
+ "diagnostics": "Failed to find practitioner from system"
63
+ }
64
+ ]
65
+ }
66
+ http_version:
67
+ recorded_at: Fri, 19 May 2017 15:34:36 GMT
68
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe LifenFhir::Category do
4
+
5
+ let(:category) { LifenFhir::Category.new }
6
+
7
+ describe ':valid?' do
8
+
9
+ it 'default case is valid' do
10
+ expect(category).to be_valid
11
+ end
12
+
13
+ it 'unknown case is not valid' do
14
+ category.code = "UNKOWN CODE"
15
+
16
+ expect(category).to_not be_valid
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe LifenFhir::CommunicationRequest do
4
+
5
+
6
+ let(:medium1) { LifenFhir::Medium.new(uuid: "valid-medium-uuid-1") } #valid_channel_uuid
7
+ let(:medium2) { LifenFhir::Medium.new(uuid: "valid-medium-uuid-2") }
8
+
9
+ let(:sender) { LifenFhir::Practitioner.new(uuid: "valid-sender-uuid") } #valid_sender_uuid
10
+
11
+ let(:recipient1) { LifenFhir::Practitioner.new(uuid: "valid-recipient-uuid-1") }
12
+ let(:recipient2) { LifenFhir::Practitioner.new(uuid: "valid-recipient-uuid-2") }#valid_recipient_uuid
13
+
14
+ let(:binary) { LifenFhir::Binary.new(uuid: "valid-binary-uuid") }
15
+
16
+ let(:attachment) { LifenFhir::Attachment.new(title: "Master Plan", path: File.dirname(__FILE__) + "/support/master_plan.pdf", content_type: "application/pdf") }
17
+
18
+ let(:patient) { LifenFhir::Patient.new(first_name: "Jean", last_name: "Dupond", birthdate: Date.new(2000,1,1)) }
19
+
20
+
21
+
22
+ describe ':send multi-recipients with a binary' do
23
+
24
+ let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, recipient2], medium: [medium1, medium2], binary: binary, patient: patient) }
25
+
26
+ it 'works' do
27
+ VCR.use_cassette "communication_request/send/valid_attributes_binary" do
28
+ communication_request.send
29
+ end
30
+
31
+ expect(communication_request.uuid).to_not be_nil
32
+ expect(communication_request.number_communications).to eq(2)
33
+ end
34
+ end
35
+
36
+ describe ':send multi-recipients with an attachment' do
37
+
38
+ let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, recipient2], medium: [medium1, medium2], attachment: attachment, patient: patient) }
39
+
40
+ it 'works' do
41
+ VCR.use_cassette "communication_request/send/valid_attributes" do
42
+ communication_request.send
43
+ end
44
+
45
+ expect(communication_request.uuid).to_not be_nil
46
+ expect(communication_request.number_communications).to eq(2)
47
+ end
48
+ end
49
+
50
+ describe 'invalid medium' do
51
+ let(:invalid_medium) { LifenFhir::Medium.new(uuid: "invalid-medium-uuid") }
52
+ let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, recipient2], medium: [invalid_medium, medium2], binary: binary, patient: patient) }
53
+
54
+ it 'raises an error' do
55
+
56
+ VCR.use_cassette "communication_request/send/invalid_medium" do
57
+ expect{
58
+ communication_request.send
59
+ }.to raise_error LifenFhir::Error
60
+ end
61
+ end
62
+ end
63
+
64
+ end