Skip to content

Instantly share code, notes, and snippets.

@dnewber
Last active March 11, 2020 17:33
Show Gist options
  • Select an option

  • Save dnewber/cb626308fdd9f165e2ac009096023f98 to your computer and use it in GitHub Desktop.

Select an option

Save dnewber/cb626308fdd9f165e2ac009096023f98 to your computer and use it in GitHub Desktop.
Middleware v2 Usage Guide

Middleware v2 Usage Guide

Middleware requests require a valid authorization token header:

Authorization: Bearer TOKEN
Content-Type: application/json
...

PointClickCare Facilities:

GET

/v2/pcc/org/{orgUuid}/fac

Example Response:

{
    "data": [{
            "attributes": {
                "maphabit": {
                    "autosync": false,
                    "mh_community_id": null
                },
                "pcc": {
              
                    "orgId": 1504963571,
                    "orgName": "apiusmstr1 training db",
                    "orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
                    "phone": "(813) 555-8836", 
                    ...
                }
            },
            "id": "1D56E037-24C5-409F-A414-C9718B519300.12",
            "links": {
                "self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/12"
            },
            "relationships": {
                "patients": {
                    "links": {
                        "related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?filter%5Bpcc.facId%5D=12"
                    }
                },
                "pickLists": {
                    "links": {
                        "related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?filter%5Bpcc.facId%5D=12"
                    }
                }
            },
            "type": "PCC2Fac"
        }
    ],
    "links": {
        "first": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac?page%5Boffset%5D=0&page%5Blimit%5D=20",
        "last": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac?page%5Boffset%5D=0&page%5Blimit%5D=20",
        "self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac?page%5Boffset%5D=0&page%5Blimit%5D=20"
    },
    "meta": {
        "total": 1
    }
}

PointClickCare Facility:

GET
/v2/pcc/org/{orgUuid}/fac/{facId}

Example Response:

{
	"data": {
		"attributes": {
			"maphabit": {
				"autosync": false,
				"mh_community_id": null
			},
			"pcc": {
				"facId": 12,
				"facilityCode": "6615",
				"facilityName": "(train) FACILITY_12",
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
				"phone": "(813) 555-8836",
			...
			}
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.12",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/12"
		},
		"relationships": {
			"patients": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?filter%5Bpcc.facId%5D=12"
				}
			},
			"pickLists": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?filter%5Bpcc.facId%5D=12"
				}
			}
		},
		"type": "PCC2Fac"
	},
	"links": {
		"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/12"
	}
}

PATCH Note: Only the maphabit fields are available for update.

/v2/pcc/org/{orgUuid}/fac/{facId}

{
	"data": {
		"type": "PCC2Fac",
		"id": "1D56E037-24C5-409F-A414-C9718B519300.44",
		"attributes": {
			"maphabit": {
				"mh_community_id": 15
			}
		}
	}
}

To Unlink, send PATCH with mh_community_id as null

Example Response:

{
	"data": {
		"attributes": {
			"maphabit": {
				"autosync": false,
				"mh_community_id": 15
			},
			"pcc": {
				"orgId": 1504963571,
				"orgName": "apiusmstr1 training db",
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
				...
			}
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.44",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/44"
		},
		"relationships": {
			"patients": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?filter%5Bpcc.facId%5D=44"
				}
			},
			"pickLists": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?filter%5Bpcc.facId%5D=44"
				}
			}
		},
		"type": "PCC2Fac"
	},
	"links": {
		"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/44"
	}
}

PointClickCare Patients:

GET
/v2/pcc/org/{orgUuid}/patient

Filter patients with URL parameters:

  • Pagination:

     page[limit]=5
     page[offset]=0
    
  • Filtering:

     filter[FIELD NAME]=VALUE
     filter[pcc.facId]=22
    
  • Sorting:

     sort=FIELD NAME
     sort=pcc.lastName
    
  • Search Query:

     filter[_q]=SEARCH VALUE
     filter[_q]=Abernathy
    
  • Search within a specific Field:

     filter[FIELD NAME]=^SEARCH VALUE
     filter[pcc.firstName]=^betty
     filter[pcc.lastName]=^abernathy 
    
  • Date filters must be in {"$date": "YYYY-MM-DDT00:00:00"} format:

     {"$date": "1948-09-11T00:00:00"}
     filter[pcc.birthDate]={"$date": "1948-09-11T00:00:00"}
    
  • You can also filter on MapHabit fields. To get all patients in a community:

     filter[maphabit.mh_community_id]=15
    

Note:

Example URL with filters and pagination:

https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?filter%5Bpcc.facId%5D=22&page%5Blimit%5D=5&page%5Boffset%5D=0&sort=pcc.lastName&filter%5Bpcc.lastName%5D=%5EAbbott

Example Response:

{
	"data": [{
		"attributes": {
			"maphabit": {
				"mh_community_id": null,
				"mh_user_id": null
			},
			"pcc": {
				"facId": 22,
				"patientId": 7792,
				"firstName": "Louie",
				"languageDesc": "English",
				"lastName": "Abbott",
				"orgId": 1504963571,
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
				"roomId": 2083,
				...
			}
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.7792",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient/7792"
		},
		"relationships": {
			"facility": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/22"
				}
			}
		},
		"type": "PCC2Patient"
	}],
	"links": {
		"first": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?page%5Boffset%5D=0&page%5Blimit%5D=5&filter%5Bpcc.facId%5D=22",
		"last": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?page%5Boffset%5D=100&page%5Blimit%5D=5&filter%5Bpcc.facId%5D=22",
		"next": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?page%5Boffset%5D=5&page%5Blimit%5D=5&filter%5Bpcc.facId%5D=22",
		"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient?page%5Boffset%5D=0&page%5Blimit%5D=5&filter%5Bpcc.facId%5D=22"
	},
	"meta": {
		"total": 1
	}
}

PointClickCare Patient :

GET
/v2/pcc/org/{orgUuid}/patient/{patientId}

Example Response:

{
	"data": {
		"attributes": {
			"maphabit": {
				"mh_community_id": null,
				"mh_user_id": null
			},
			"pcc": {
				"facId": 22,
				"firstName": "Louie",
				"hasPhoto": true,
				"lastName": "Abbott",
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
				"patientId": 7792,
				"patientStatus": "Current",
				...
			}
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.7792",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient/7792"
		},
		"relationships": {
			"facility": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/22"
				}
			}
		},
		"type": "PCC2Patient"
	},
	"links": {
		"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient/7792"
	}
}

PATCH
/v2/pcc/org/{orgUuid}/patient/{patientId}

Example body for linking a resident:

{
	"data": {
		"type": "PCC2Patient",
		"id": "1D56E037-24C5-409F-A414-C9718B519300.7792",
		"attributes": {
			"maphabit": {
				"mh_community_id": 15,
				"mh_user_id": "267"
			}
		}
	}
}

Example body for unlinking a resident:

{
	"data": {
		"type": "PCC2Patient",
		"id": "1D56E037-24C5-409F-A414-C9718B519300.7792",
		"attributes": {
			"maphabit": {
				"mh_user_id": null
			}
		}
	}
}

Example Response:

{
	"data": {
		"attributes": {
			"maphabit": {
				"mh_community_id": 15,
				"mh_user_id": 267
			},
			"pcc": {
				"firstName": "Louie",
				"hasPhoto": true,
				"lastName": "Abbott",
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
				...
			}
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.7792",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient/7792"
		},
		"relationships": {
			"facility": {
				"links": {
					"related": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/fac/22"
				}
			}
		},
		"type": "PCC2Patient"
	},
	"links": {
		"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/patient/7792"
	}
}

POST

/v2/pcc/org/{orgUuid}/patientGroup

Bulk create MapHabit residents from PCC patients

  • The id must be the residents group_id.
  • The patients attribute accepts multiple patient objects.

Example Request Body:

{
	"data": {
		"type": "PCC2PatientGroup",
		"id": "1",
		"attributes": {
			"patients": [{
				"patientId": "6209",
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300"
			}]
		}
	}
}

A successful request will respond with a 204 Success - No Content. Once residents are created, they must be linked with a PATCH /v2/pcc/org/{orgUuid}/patient/{patientId}.

MapHabit Users :

GET

Get a list of MH users linked to a PCC user

/v2/pcc/org/{orgUuid}/user/{pccUserId}

Example Response:

{
	"data": {
		"attributes": {
			"mhUsers": [{
				"communityId": 15,
				"refreshToken": "TOKEN.HERE",
				"userId": 81,
				"username": "ajeesh.ag@experionglobal.com"
			}],
			"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
			"pccUserId": 92437
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.92437",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/user/92437"
		},
		"type": "PCCMaphabitUser"
	},
	"links": {
		"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/user/92437"
	}
}

PATCH

Link/Unlink MH Users with PCC users

/v2/pcc/org/{orgUuid}/user/{pccUserId}

Link a user example:

GET the PCC user, and then add the MH user to mhUsers

{"data":{"attributes":{"mhUsers":[{"userId":81,"communityId":15,"username":"ajeesh.ag@experionglobal.com","refreshToken":"TOKEN.HERE"}],"orgUuid":"1D56E037-24C5-409F-A414-C9718B519300","pccUserId":92437},"id":"1D56E037-24C5-409F-A414-C9718B519300.92437","links":{"self":"https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/user/92437"},"type":"PCCMaphabitUser"}}

Unlink a user example:

Remove the user from mhUsers

{"data":{"attributes":{"mhUsers":[],"orgUuid":"1D56E037-24C5-409F-A414-C9718B519300","pccUserId":92437},"id":"1D56E037-24C5-409F-A414-C9718B519300.92437","links":{"self":"https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/user/92437"},"type":"PCCMaphabitUser"}}

Example Response:

{
	"data": {
		"attributes": {
			"mhUsers": [{
				"userId": 81,
				"communityId": 15,
				"username": "ajeesh.ag@experionglobal.com",
				"refreshToken": "TOKEN.HERE"
			}],
			"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
			"pccUserId": 92437
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.92437",
		"links": {
			"self": "https://api-staging.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/user/92437"
		},
		"type": "PCCMaphabitUser"
	}
}

Picklist Mappings:

About the PickList Mapping:

MapHabit values come from the master API: https://api.development.maphabit.com/v1/users/master

Which provides the IDs used for mapping:

"ethnicity": [{
			"id": 1,
			"title": "Asian"
		}, {
			"id": 2,
			"title": "African American"
		}, {
			"id": 3,
			"title": "Caucasian"
		}, ...

Default mappings are set with pcc_id: -1

For example, this sets MapHabit's Caucasian value mh_id: 3 as the picklist's default value:

{"mh_id": 3, "pcc_id": -1}

GET

Get picklist values

/v2/pcc/org/{orgUuid}/pickList

Specify facilityId and field name with filters:

filter[pcc.facId]=44
filter[pcc.name]=race

Example URL with filters:

https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?filter%5Bpcc.facId%5D=44&filter%5Bpcc.name%5D=race

Example Response:

    {
	"data": [{
		"attributes": {
			"maphabit": [{
				"mh_id": 3,
				"pcc_id": -1
			}],
			"pcc": {
				"elements": [{
					"description": "- UTD",
					"id": 9149,
					"metadata": {}
				}, {
					"description": "Asian",
					"id": 11920,
					"metadata": {}
				}, {
					"description": "Black, not of Hispanic origin",
					"id": 9075,
					"metadata": {}
				},{
					"description": "- Declined to Specify",
					"id": 11675,
					"metadata": {}
				}],
				"facId": 44,
				"name": "race",
				"orgId": 1504963571,
				"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
				"pickListId": 10
			}
		},
		"id": "1D56E037-24C5-409F-A414-C9718B519300.44.10",
		"links": {
			"self": "https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList/44.10"
		},
		"type": "PCC2PickList"
	}],
	"links": {
		"first": "https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?page%5Blimit%5D=20&page%5Boffset%5D=0&filter%5Bpcc.facId%5D=44&filter%5Bpcc.name%5D=race",
		"last": "https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?page%5Blimit%5D=20&page%5Boffset%5D=0&filter%5Bpcc.facId%5D=44&filter%5Bpcc.name%5D=race",
		"self": "https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList?page%5Blimit%5D=20&page%5Boffset%5D=0&filter%5Bpcc.facId%5D=44&filter%5Bpcc.name%5D=race"
	},
	"meta": {
		"total": 1
	}
}

PATCH

Set picklist values

/v2/pcc/org/{orgUuid}/pickList/{facId.pickListID}

Update the picklist's attributes to set the mappings.

Example URL:

(For facility 44, picklist 10)

https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList/44.10

Example Request Body:

This request adds a new mapping for "African American" (mh_id: 2) and "Black" (pcc_id: 9075).

{
"data": {
	"type": "PCC2PickList",
	"id": "1D56E037-24C5-409F-A414-C9718B519300.44.10",
	"attributes": {
		"maphabit": [{
			"mh_id": 3,
			"pcc_id": -1
		}, {
			"pcc_id": 9075,
			"mh_id": 2
		}]
	}
    }
}

Example Response:

{
"data": {
	"attributes": {
		"maphabit": [{
			"mh_id": 3,
			"pcc_id": -1
		}, {
			"mh_id": 2,
			"pcc_id": 9075
		}],
		"pcc": {
			"elements": [{
				"description": "- UTD",
				"id": 9149,
				"metadata": {}
			}, {
				"description": "Black, not of Hispanic origin",
				"id": 9075,
				"metadata": {}
			}, ...],
			"facId": 44,
			"name": "race",
			"orgId": 1504963571,
			"orgUuid": "1D56E037-24C5-409F-A414-C9718B519300",
			"pickListId": 10
		}
	},
	"id": "1D56E037-24C5-409F-A414-C9718B519300.44.10",
	"links": {
		"self": "https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList/44.10"
	},
	"type": "PCC2PickList"
},
"links": {
	"self": "https://api-dev.middleware.maphabit.com/v2/pcc/org/1D56E037-24C5-409F-A414-C9718B519300/pickList/44.10"
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment