• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RoundingWell / care-ops-frontend / ed611366-b6f5-4b86-8a11-627f5a40df46

pending completion
ed611366-b6f5-4b86-8a11-627f5a40df46

Pull #1056

circleci

nmajor25
Update error handling & parse phone number input
Pull Request #1056: Add outreach UI for verifying users via a texted and/or emailed code

1669 of 1672 branches covered (99.82%)

Branch coverage included in aggregate %.

79 of 80 new or added lines in 5 files covered. (98.75%)

4 existing lines in 1 file now uncovered.

5660 of 5665 relevant lines covered (99.91%)

315.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.95
/src/js/outreach/entities/index.js
1
import Radio from 'backbone.radio';
2
import fetcher, { handleJSON } from 'js/base/fetch';
3
import { v4 as uuid } from 'uuid';
4

5
function getRelationship(id, type) {
6
  return { data: { type, id } };
4✔
7
}
8

9
let token;
10

11
Radio.reply('auth', {
10✔
12
  setToken(tokenString) {
13
    token = tokenString;
3✔
14
  },
15
  getToken() {
16
    return token;
38✔
17
  },
18
});
19

20
function getToken({ dob, actionId }) {
UNCOV
21
  const data = {
×
22
    type: 'patient-tokens',
23
    id: uuid(),
24
    attributes: {
25
      reason: 'outreach',
26
      birth_date: dob,
27
    },
28
    relationships: {
29
      action: getRelationship(actionId, 'patient-actions'),
30
    },
31
  };
32

UNCOV
33
  return fetcher('/api/patient-tokens', {
×
34
    method: 'POST',
35
    data: JSON.stringify({ data }),
36
  })
37
    .then(handleJSON)
38
    .then(({ data: { attributes } }) => {
UNCOV
39
      Radio.request('auth', 'setToken', attributes.token);
×
UNCOV
40
      return Promise.resolve(attributes.token);
×
41
    });
42
}
43

44
function getPatientInfo({ actionId }) {
45
  return fetcher(`/api/outreach?filter[action]=${ actionId }`, {
8✔
46
    method: 'GET',
47
  })
48
    .then(handleJSON)
49
    .then(({ data }) => {
50
      return data;
7✔
51
    });
52
}
53

54
function createVerificationCode({ patientId }) {
55
  return fetcher(`/api/outreach/${ patientId }`, {
8✔
56
    method: 'POST',
57
    data: {},
58
  })
59
    .then(handleJSON);
60
}
61

62
function validateVerificationCode({ patientId, code }) {
63
  const data = {
6✔
64
    patient_id: patientId,
65
    otp: code,
66
  };
67

68
  return fetcher('/api/outreach/auth', {
6✔
69
    method: 'POST',
70
    data: JSON.stringify({ data }),
71
  })
72
    .then(handleJSON)
73
    .then(({ data: { attributes } }) => {
74
      Radio.request('auth', 'setToken', attributes.token);
3✔
75
      return Promise.resolve(attributes.token);
3✔
76
    });
77
}
78

79
function optInPostRequest({ inputData }) {
80
  const data = {
2✔
81
    first_name: inputData.get('firstName'),
82
    last_name: inputData.get('lastName'),
83
    birth_date: inputData.get('dob'),
84
    phone: inputData.get('phone'),
85
    email: inputData.get('email'),
86
  };
87

88
  return fetcher('/api/outreach', {
2✔
89
    method: 'POST',
90
    data: JSON.stringify({ data }),
91
  })
92
    .then(handleJSON);
93
}
94

95
function postResponse({ formId, actionId, response }) {
96
  const data = {
2✔
97
    type: 'form-responses',
98
    id: uuid(),
99
    attributes: { response },
100
    relationships: {
101
      action: getRelationship(actionId, 'patient-actions'),
102
      form: getRelationship(formId, 'forms'),
103
    },
104
  };
105

106
  return fetcher(`/api/actions/${ actionId }/relationships/form-responses`, {
2✔
107
    method: 'POST',
108
    data: JSON.stringify({ data }),
109
  })
110
    .then(handleJSON);
111
}
112

113
export {
114
  getToken,
115
  getPatientInfo,
116
  postResponse,
117
  optInPostRequest,
118
  createVerificationCode,
119
  validateVerificationCode,
120
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc