forked from inflection-zone/rean-admin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from REAN-Foundation/search_for_types
Search for types
- Loading branch information
Showing
36 changed files
with
2,013 additions
and
1,591 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function setActiveRoles(userRoles) { | ||
userRoles.forEach((userRoleType) => { | ||
if (userRoleType.RoleName === 'System admin' || | ||
userRoleType.RoleName === 'System user' || | ||
userRoleType.RoleName === 'Tenant admin' || | ||
userRoleType.RoleName === 'Tenant user' || | ||
userRoleType.RoleName === 'Patient' || | ||
userRoleType.RoleName === 'Doctor') { | ||
userRoleType.isActive = true; | ||
} else { | ||
userRoleType.isActive = false; | ||
} | ||
}); | ||
return userRoles; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { searchLabRecordTypes } from "$routes/api/services/reancare/lab-record-types"; | ||
import type { RequestEvent } from "@sveltejs/kit"; | ||
|
||
////////////////////////////////////////////////////////////// | ||
|
||
export const GET = async (event: RequestEvent) => { | ||
|
||
const sessionId = event.locals.sessionUser.sessionId; | ||
const searchParams: URLSearchParams = event.url.searchParams; | ||
const typeName = searchParams.get('typeName') ?? undefined | ||
const displayName = searchParams.get('displayName') ?? undefined | ||
const sortBy = searchParams.get('sortBy') ?? 'CreatedAt'; | ||
const sortOrder = searchParams.get('sortOrder') ?? 'ascending'; | ||
const itemsPerPage_ = searchParams.get('itemsPerPage'); | ||
const itemsPerPage = itemsPerPage_ ? parseInt(itemsPerPage_) : 10; | ||
const pageIndex_ = searchParams.get('pageIndex'); | ||
const pageIndex = pageIndex_ ? parseInt(pageIndex_) : 0; | ||
|
||
try { | ||
const searchParams = { | ||
typeName, | ||
displayName, | ||
orderBy: sortBy, | ||
order: sortOrder, | ||
itemsPerPage, | ||
pageIndex, | ||
}; | ||
console.log("Search parms: ", searchParams); | ||
const response = await searchLabRecordTypes(sessionId, searchParams); | ||
const labRecords = response.Data.LabRecordTypes; | ||
console.log("labRecords", JSON.stringify(response, null, 2)); | ||
return new Response(JSON.stringify(labRecords)); | ||
} catch (err) { | ||
console.error(`Error retriving lab records: ${err.message}`); | ||
return new Response(err.message); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { setActiveRoles } from "$lib/utils/user.active.role"; | ||
import { searchRoleTypes } from "$routes/api/services/reancare/person-role-types"; | ||
import type { RequestEvent } from "@sveltejs/kit"; | ||
|
||
////////////////////////////////////////////////////////////// | ||
|
||
export const GET = async (event: RequestEvent) => { | ||
|
||
const sessionId = event.locals.sessionUser.sessionId; | ||
const searchParams: URLSearchParams = event.url.searchParams; | ||
const roleName = searchParams.get('roleName') ?? undefined | ||
const sortBy = searchParams.get('sortBy') ?? 'CreatedAt'; | ||
const sortOrder = searchParams.get('sortOrder') ?? 'ascending'; | ||
const itemsPerPage_ = searchParams.get('itemsPerPage'); | ||
const itemsPerPage = itemsPerPage_ ? parseInt(itemsPerPage_) : 10; | ||
const pageIndex_ = searchParams.get('pageIndex'); | ||
const pageIndex = pageIndex_ ? parseInt(pageIndex_) : 0; | ||
|
||
try { | ||
const searchParams = { | ||
name:roleName, | ||
orderBy: sortBy, | ||
order: sortOrder, | ||
itemsPerPage, | ||
pageIndex, | ||
}; | ||
console.log("Search parms: ", searchParams); | ||
const response = await searchRoleTypes(sessionId, searchParams); | ||
const roles = response.Data.Roles; | ||
roles.Items = setActiveRoles(roles.Items ?? []); | ||
console.log("roles", JSON.stringify(response, null, 2)); | ||
return new Response(JSON.stringify(roles)); | ||
} catch (err) { | ||
console.error(`Error retriving roles: ${err.message}`); | ||
return new Response(err.message); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.