@@ -65,22 +65,58 @@ export const createPatient = createAction(
6565 return { patient : newPatient } ;
6666 } ,
6767 ( patient ) => {
68- const body = {
69- firstNames : patient . firstName ,
70- lastNames : patient . lastName ,
71- gender : patient . gender ,
72- dateOfBirth : patient . dob . toISOString ( ) ,
73- address : patient . address ,
74- mrn : patient . mrn ,
75- tumorType : patient . tumorType ,
76- isSurgical : ( patient . surgical ) ? 'true' : 'false' ,
77- phone : patient . phone ,
78- email : patient . email ,
79- } ;
68+ const query = `mutation insertPatient (
69+ $firstname: String!,
70+ $surname: String!,
71+ $gender: String!,
72+ $dob: String!,
73+ $address: String!,
74+ $mrn: Int!,
75+ $tumorType: String!,
76+ $surgical: String!,
77+ $phone: String!,
78+ $email: String!
79+ ) {
80+ patient: createPatient(
81+ firstname: $firstname,
82+ surname: $surname,
83+ gender: $gender,
84+ dob: $dob,
85+ address: $address,
86+ mrn: $mrn,
87+ tumorType: $tumorType,
88+ surgical: $surgical,
89+ phone: $phone,
90+ email: $email
91+ ) {
92+ id,
93+ mrn,
94+ surname
95+ firstname,
96+ gender,
97+ tumorType,
98+ surgical,
99+ dob,
100+ address,
101+ phone,
102+ email,
103+ }
104+ }` ;
105+ const variables = `{
106+ "firstname": "${ patient . firstName } ",
107+ "surname": "${ patient . lastName } ",
108+ "gender": "${ patient . gender } ",
109+ "dob": "${ patient . dob . toISOString ( ) } ",
110+ "address": "${ patient . address } ",
111+ "mrn": ${ patient . mrn } ,
112+ "tumorType": "${ patient . tumorType } ",
113+ "surgical": "${ ( patient . surgical ) ? 'true' : 'false' } ",
114+ "phone": "${ patient . phone } ",
115+ "email": "${ patient . email } "
116+ }` ;
80117 return {
81- endpoint : `${ process . env . BACKEND_API_URL } /patient/` ,
82- method : 'POST' ,
83- body : body ,
118+ query : query ,
119+ variables : variables ,
84120 success : updatePatient ,
85121 error : removePatient ,
86122 } ;
@@ -135,7 +171,7 @@ export const followUpPDF = createAction(
135171export const updatePatient = createAction (
136172 UPDATE_PATIENT ,
137173 ( patient , originalPayload ) => {
138- return { patient, token : originalPayload . patient . token } ;
174+ return { patient : patient . patient , token : originalPayload . patient . token } ;
139175 }
140176) ;
141177
@@ -149,7 +185,7 @@ export const removePatient = createAction(
149185const fetchPatient = createAction (
150186 FETCH_PATIENT ,
151187 ( patientJson ) => {
152- return { patient : patientJson } ;
188+ return { patient : patientJson . patient } ;
153189 }
154190) ;
155191
@@ -166,7 +202,7 @@ const setPatientSearchResults = createAction(
166202 SET_PATIENT_SEARCH_RESULTS ,
167203 ( patientsJson ) => {
168204 return {
169- patients : patientsJson
205+ patients : patientsJson . patients
170206 } ;
171207 }
172208) ;
@@ -175,8 +211,23 @@ export const searchPatients = createAction(
175211 SEARCH_PATIENTS ,
176212 null ,
177213 ( patientId ) => {
214+ const query = `query getAllPatients {
215+ patients {
216+ id,
217+ mrn,
218+ surname
219+ firstname,
220+ gender,
221+ tumorType,
222+ surgical,
223+ dob,
224+ address,
225+ phone,
226+ email,
227+ }
228+ }` ;
178229 return {
179- endpoint : ` ${ process . env . BACKEND_API_URL } /patient/` ,
230+ query : query ,
180231 success : setPatientSearchResults
181232 } ;
182233 }
@@ -188,8 +239,32 @@ export const fetchPatientFromServer = createAction(
188239 return { patientId : patientId } ;
189240 } ,
190241 ( patientId ) => {
242+ const query = `query getPatient ($id: Int!) {
243+ patient(id: $id) {
244+ id,
245+ mrn,
246+ ehrId,
247+ surname
248+ firstname,
249+ gender,
250+ tumorType,
251+ surgical,
252+ dob,
253+ address,
254+ phone,
255+ email,
256+ allergies{
257+ name,
258+ date
259+ }
260+ }
261+ }` ;
262+ const variables = `{
263+ "id": ${ patientId }
264+ }` ;
191265 return {
192- endpoint : `${ process . env . BACKEND_API_URL } /patient/${ patientId } ` ,
266+ query : query ,
267+ variables : variables ,
193268 success : fetchPatient
194269 } ;
195270 }
0 commit comments