bcgov / digital-journeys

PSA Forms System
https://bcgov.github.io/digital-journeys/
Apache License 2.0
8 stars 7 forks source link

Cold/Flu: API End Points #1000

Closed ca-liu closed 1 year ago

ca-liu commented 1 year ago

User Story A short, simple description of a feature or issue told from the perspective of the user. “As a user wanting to register my worksite for a clinic, I did find my worksite listed but I have reasons to register our team as a separate clinic”

Methods:

path = https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_{CUSTOM_PATH}/

CUSTOM PATH: ministries HTTP METHOD: GET Output: return array of ministries Ex:

[
    {
        ministry_id: 1,
        m_name: "Ministry of Transportation",
        is_active: 1,
        date_updated: DATETIME
    },
    {
        ministry_id: 2,
        m_name: "Ministry of Heath",
        is_active: 0,
        date_updated: DATETIME
    }
]

  CUSTOM PATH: worksites_ministries_joined/ministry_id? HTTP METHOD: GET Output: return array of worksite_ministries Ex:

[
    {
        wm_id: 1,
        worksite: {
            Worksite_id: 1,
            Street_number: "12345",
            Street_name: "Burrard St.",
            City: "Victoria",
            Province: "BC"
        }
    },
    {
        wm_id: 2,
        worksite: {
            Worksite_id: 2,
            Street_number: "4567",
            Street_name: "Mian St.",
            City: "Victoria",
            Province: "BC"
        }
    }
]

  CUSTOM PATH: vm_registrations_worksites_joined?{worksite_id} HTTP METHOD: GET Output: return array of registrations Ex:

[
    {
        Registration: {
            number_of_employees: 10,
            is_closed: 0,
            year: 2023,
            deleted_ind: 0,
        },
        Primary_Contact: {
            first_name: "Bob",
            last_name: "Builder",
            email: "bob.builder@gov.bc.ca"
        },
        m_name: "Ministry of Transportation"
    },
    {
        Registration: {
            number_of_employees: 3,
            is_closed: 0,
            year: 2023,
            deleted_ind: 0,
        },
        Primary_Contact: {
            first_name: "Kim",
            last_name: "Possible",
            email: "kim.possible@gov.bc.ca"
        },
        m_name: "Ministry of Health"
    },
]

  CUSTOM PATH: insert_worksite_registgration HTTP METHOD: POST Input: forms JSON Backend Logic: See documentation from Mike

New worksite: https://app.zenhub.com/files/439477060/e5d760ab-4fcc-4b75-a990-873ac1700f51/download

Existing worksite: https://app.zenhub.com/files/439477060/f0bcf722-feff-4772-b637-eca9aebb9878/download

Output: return http success / fail message

CUSTOM PATH: delete_registration/ HTTP METHOD: POST Input: { "application_id": 1} Output: return http success / fail message

Acceptance Criteria

iman-jamali-fw commented 1 year ago

Great question! year would be the year that the form was first submitted. We also have a last_modified_date_time row in the database to capture changes.

Perfect! I added year, a hidden field in the form with logic that only captures the year during the initial submission.

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw

Based on the updated ERD Caleb has shared, the Endpoints updated accordingly. Please let me know if you run any issues

ca-liu commented 1 year ago

Thank you so much, @mikeshi-bcgov and @iman-jamali-fw

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw And the request example for endpoint https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_worksite_registrationn/, is now like:

var postdata = { "application_id": 1, "city": "city_2", "closed_reason": "closed_reason_3", "country": "country_4", "date_modified": "2023-04-18T15:16:10-07:00", "date_submitted": "2023-04-18T15:16:10-07:00", "is_closed": "is_closed_7", "is_relocating": "is_relocating_8", "ministry_id": 9, "number_of_employees": 10, "postal_code": "postal_code_11", "primary_email": "primary_email_12", "primary_first_name": "primary_first_name_13", "primary_last_name": "primary_last_name_14", "primary_phone": "primary_phone_15", "province": "province_16", "secondary_email": "secondary_email_17", "secondary_first_name": "secondary_first_name_18", "secondary_last_name": "secondary_last_name_19", "secondary_phone": "secondary_phone_20", "special_instructions": "special_instructions_21", "street_name": "street_name_22", "street_number": "street_number_23", "year": 24}

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov Works great! Thanks.

There is just one change in the URL, the last word in the insert URL has an extra n. Can you fix that? `\testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insertworksiteregistrationn

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw

Sorry, corrected

mikeshitelus commented 1 year ago

@iman-jamali-fw and @bhumin-fw A new API endpoint for existing Worksite is now available for your test HTTP POST (https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_registration_existing_worksite/)

Request Example: var postdata = { "application_id": 1, "closed_reason": "closed_reason_2", "date_modified": "2023-04-19T09:23:55-07:00", "date_submitted": "2023-04-19T09:23:55-07:00", "is_closed": "is_closed_5", "is_relocating": "is_relocating_6", "ministry_id": 7, "number_of_employees": 8, "primary_email": "primary_email_9", "primary_first_name": "primary_first_name_10", "primary_last_name": "primary_last_name_11", "primary_phone": "primary_phone_12", "secondary_email": "secondary_email_13", "secondary_first_name": "secondary_first_name_14", "secondary_last_name": "secondary_last_name_15", "secondary_phone": "secondary_phone_16", "special_instructions": "special_instructions_17", "worksite_id": 18, "year": 19}

Response: { "value": [{ "primary_contact_id": 1, "registrations_id": 2, "secondary_contact_id": 3}]}

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov

HTTP POST (https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_registration_existing_worksite/)

So this endpoint will actually update an existing registration? Because it's a post I thought it is adding a new entry.

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw This endpoint will add a new entry in table "registration" based on an existing WorkSite.

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov

Ok. I think I don't know the exact requirement of adding based on the existing worksite feature. Can you help me understand the difference between insert_registration and insert_existing_registration? Does the existing require an existing worksite_id in the body?

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw

Base on existing WorkSite, not existing Registration. Which assuming you already have ministry_id and worksite_id.

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw

Actually you can also use those basic endpoints for each table to achieve the same, just a few more steps on Form side.

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov That makes sense. Thank you

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov To confirm, for any null values in the form I should instead send a string of the word "no"?

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw

Should be BLANK

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov

By blank you mean that field should not exist in the body or have a string of "blank"? :)

mikeshi-bcgov commented 1 year ago

@iman-jamali-fw For instance, here are what we received for fields "closed_reason" and "special_istructions" for application_id 8415/8437, not sure what you have posted, if no value for the field should like closed_reason.

image

bhumin-fw commented 1 year ago

@mikeshi-bcgov

A new API endpoint for new worksite and registration HTTP POST https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_worksite_registration

Do we have update endpoint ready for the same? we will pass same object again in request body. We call above same url using PUT method HTTP PUT https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_worksite_registration(301) note: 301 is an application id

Same for below too.

A new API endpoint for existing Worksite is now available for your test HTTP POST (https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_registration_existing_worksite/)

mikeshi-bcgov commented 1 year ago

@bhumin-fw

Because this kind of endpoint dealing with multiple tables is based on Stored Procedure, will only accept POST request. How about I create a separate endpoint named like "https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_update_worksite_registration"?

If this works for you, I will create tomorrow.

bhumin-fw commented 1 year ago

@mikeshi-bcgov

Yes Mike, Separate endpoints work fine. Please consider that I'll be able to send same object in update request like which sending in POST. I'll have application_id so let me know how should I pass application_id in that, which help to update data on dataware house.

Please keep it in your list that we need both endpoints with update requirements.

  1. worksite and registrations https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_worksite_registration

  2. registration under existing worksite https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_insert_registration_existing_worksite/

mikeshi-bcgov commented 1 year ago

@bhumin-fw sounds good, will work on these tomorrow, and update you when available

mikeshitelus commented 1 year ago

@bhumin-fw Endpoint HTTP POST (https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_update_worksite_registration/) has been created, please test.

bhumin-fw commented 1 year ago

@mikeshitelus @mikeshi-bcgov

I did send 2 request one for _insert and one for _update. Could you please check and let me know both received on your end or not? One more can we connect on a call to discuss about other API? let me know what is a preferred way to connect with you on a call.

mikeshitelus commented 1 year ago

@bhumin-fw seems only received the _insert request, record was inserted.

mikeshitelus commented 1 year ago

@bhumin-fw Endpoint HTTP POST (https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_update_registration_existing_worksite/) is now available for testing too.

bhumin-fw commented 1 year ago

@mikeshitelus @mikeshi-bcgov I'm checking issue for sending second request for the update on server.

Thank you so much for the quick response here on other _update endpoints too.

mikeshitelus commented 1 year ago

@bhumin-fw

Actually every time once you have inserted/updated, you can query to confirm by yourself, if you need more fields to be expose through those joined views please let me know.

eg. https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_vw_registrations_worksites_joined?$filter=application_id eq 8511

mikeshitelus commented 1 year ago

@bhumin-fw I will be available Monday anytime after 10:00AM, please let me know what time work for you?

bhumin-fw commented 1 year ago

@mikeshitelus @mikeshi-bcgov

I'm having my onboarding task on that day. how about 2 or 2:30pm on Monday?

mikeshi-bcgov commented 1 year ago

@bhumin-fw Ok, let's meet 2:30 PM Monday

mikeshitelus commented 1 year ago

@bhumin-fw Endpoint for registration soft deletion is now available: HTTP POST (https://analytics-testapi.psa.gov.bc.ca/apiserver/api.rsc/ods_datamart_influenza_delete_registration/)

var postdata = { "application_id": 1};

bhumin-fw commented 1 year ago

@mikeshi-bcgov @mikeshitelus

Thank you for your prompt update on DELETE registration. Is that apply in get registration related API too (ignore soft deleted registration in the GET API list endpoint /ods_datamart_influenza_vw_registrations_worksites_joined?worksite_id=1)?

I'll update workflow and check delete registration by tomorrow afternoon. I'll keep you posted if I have any query in that.

ca-liu commented 1 year ago

Thank you, @mikeshi-bcgov and @bhumin-fw for going over the endpoint details today!

As discussed, I have updated the ticket to include the expected input/output for the end points.

mikeshi-bcgov commented 1 year ago

@bhumin-fw Yes, the "deleted" registrations will be ignored from endpoint /ods_datamart_influenza_vw_registrations_worksites_joined. As for endpoint /ods_datamart_influenza_registrations/, because it is directly with table, you need to apply filter "deleted_ind Eq null"

EduardoRamirezBC commented 1 year ago

@bhumin-fw Wondering if this ticket can move to review? It's blocking other tickets and we need to start wrapping up this project.

bhumin-fw commented 1 year ago

@EduardoRamirezBC For sure, I'll start work on some API and verify all details. Try to move this ticket to "peer review" today itself.

iman-jamali-fw commented 1 year ago

@mikeshi-bcgov

I'll move the delete related pieced from this ticket to its own ticket, #1025, and will track it from there.

bhumin-fw commented 1 year ago

@mikeshi-bcgov Thank you for all the back and forth update on endpoints. Appreciate that. Thank you @iman-jamali-fw for your follow up and pick some conversation while I was away.

I'm moving this ticket to peer review and I guess we can close this ticket in next standup.

chriscaldwell-psa commented 1 year ago

Bhumin and I went through the form today and all the data pulls in well. He has a few other things to do based on work from other tickets. This ticket can be closed.

MeghanStothers commented 1 year ago

Thanks to all for working on the famous #1000 - this one was a lift of many hands.

Stella-Archer commented 1 year ago

@bhumin-fw @iman-jamali-fw can this be closed? Does it include edit functionality in submit

bhumin-fw commented 1 year ago

@Stella-Archer Yes it include edit functionality in submit. We can close this ticket.