OpenFn / unicef-cambodia

UNICEF Cambodia - Primero Interoperability
https://openfn.github.io/unicef-cambodia/
1 stars 2 forks source link

UNICEF Flow #3 (aka User Story 4) #4

Closed aleksa-krolls closed 4 years ago

aleksa-krolls commented 4 years ago

User Story Flow 4: Sending Referrals to Primero On a daily basis, (1) fetch new client referrals from OSCaR. Then (2) check if that client exists in Primero, and either (2a) update the existing case, or (2b) create a new case.

> Step 1 (Every 24hrs): Fetch new client referrals from OSCaR

    1. OpenFn logs into OSCaR curl -X POST -v -H 'Content-Type: application/json' http://start.oscarhq-staging.com/api/v1/auth/sign_in -d '{"email": "api.user@example.com", "password": "enter-pwd" }'
  1. OpenFn sends GET request to OSCaR to list new client referrals: GET /api/v1/organizations/clients?since_date&referred_external=true
  2. OSCaR responds with list of clients (example response: list_clients_oscar.json)

> Step 2 (Diagram Step 5): Check if case exists in Primero

  1. For each OSCaR case, OpenFn searches for match in Primero: GET /api/cases/:id?locale=en&mobile=true
  2. Create 2 lists of cases: 1 set of existing cases to update, 1 set of new cases to insert

>> Step 2a (Diagram Step 9): Existing case found in Primero, update case

  1. For each matching case, send PATCH request to update existing case in Primero: PATCH /api/cases/:id

>> Step 2b (Diagram Step 9): No existing case found in Primero, create new case and referral??

  1. For each new case, send POST request to create new case in Primero: POST /api/cases

>> Step 3: Send Primero case_ids back to OSCaR

  1. OpenFn creates list of cases inserted/updated in Primero
  2. OpenFn sends PUT request to OSCaR to batch update client links: PUT to /api/v1/organizations/clients/update_links/
  3. UNICEF Diagram for user story #4
  4. Mapping template
  5. OSCaR API Docs (See LastPass for SwaggerHub password)--> "Regarding authentication to the endpoints we will be using Devise Token Auth which will support Oauth2."
  6. Primero API Docs

Credentials

  1. Primero (see LastPass primero_cp)
  2. OSCaR (see LastPass Oscar HQ)
taylordowns2000 commented 4 years ago

@aleksa-krolls , Am I right to read that step 2 and 3 are the same as flow 2? If so, I recommend that we have these steps triggered by either f2-j1 (get clients) or f2-j2 (get cases.) Better yet, it looks like that's the SAME api? In other words, this flow dissapears entirely and is handled by #3

taylordowns2000 commented 4 years ago

I am closing this issue as it's been confirmed that it will be covered by issue #3 . @aleksa-krolls , feel free to re-open if things change.