Skip to content

Commit

Permalink
feat: Include HPI CPN ID and Registration Number in the result
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallstop committed Jan 12, 2022
1 parent 25a184e commit 9042936
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 10 additions & 7 deletions demo-site/src/lib/ResultModal.svelte
Expand Up @@ -11,6 +11,8 @@
}
interface ParsedApcCert {
registrationNumber: string
hpiCpnID: string
fullName: string
issueDate: Date
expiryDate: Date
Expand All @@ -21,9 +23,9 @@

<div class="container">
{#if 'error' in message}
<div class="error-message">
{message.error}
</div>
<div class="error-message">
{message.error}
</div>
{:else if message.details !== null}
<table>
<tr>
Expand All @@ -38,9 +40,10 @@
{/each}
</table>
{:else}
<div class="error-message">
Certificate did not match any known Physioboard APC certificates. Make sure you upload the original APC certificate that was sent to you electronically.
</div>
<div class="error-message">
Certificate did not match any known Physioboard APC certificates. Make sure you
upload the original APC certificate that was sent to you electronically.
</div>
{/if}
</div>

Expand Down Expand Up @@ -78,7 +81,7 @@
border-right: 1px solid $table-border-color;
}
.error-message {
padding: 1rem;
padding: 1rem;
}
}
</style>
6 changes: 6 additions & 0 deletions src/certProfiles/physioboardAPC.ts
Expand Up @@ -36,13 +36,15 @@ export function parseCert(inputText: string[]): ParsedApcCert | null {
if (!/^70-\d{5}$/g.test(inputText[3])) {
return null
}
const registrationNumber = inputText[3]

// CPN Number, would be possible to validate check digit, but not needed
// See here for more info:
// https://www.health.govt.nz/system/files/documents/publications/10005-hpi-data-set-v1-2.pdf
if (!/^\d{2}[A-Z ]{4}$/g.test(inputText[4])) {
return null
}
const hpiCpnID = inputText[4]

// At this point we are pretty sure it's the correct certificate
// So we can start parsing the data
Expand All @@ -58,6 +60,8 @@ export function parseCert(inputText: string[]): ParsedApcCert | null {
const conditions: string | null = inputText.length == 10 ? inputText[9] : null

return {
registrationNumber,
hpiCpnID,
fullName,
issueDate,
expiryDate,
Expand All @@ -72,6 +76,8 @@ export function parseCert(inputText: string[]): ParsedApcCert | null {
* @since 0.0.0
*/
export interface ParsedApcCert {
registrationNumber: string
hpiCpnID: string
fullName: string
issueDate: Date
expiryDate: Date
Expand Down

0 comments on commit 9042936

Please sign in to comment.