Skip to content

chore(config): adds SAP filter field names to config #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
88e0f41
chore(config): adds SAP filter field names to config
makampf Jan 17, 2025
99cbc88
outsource oauth logic, init basic auth logic
Jan 31, 2025
706e95a
basic auth logic inserted, refinement of current plugin logic required
Mar 3, 2025
d28f9d4
reduce redundancy in curl call
Mar 7, 2025
ba3f58c
add gpas_only logic for ideal user input
Mar 7, 2025
9bf482b
fix redirect bug in basic auth logic
Mar 11, 2025
8be44de
add basic auth fields and event listener for psn generation
Mar 13, 2025
3432aaa
init check digit validation, refactor
Mar 19, 2025
8d58941
extend form width for error message
Mar 19, 2025
ddbfd78
add saving of sap id in gpas logic
Mar 19, 2025
97de3c6
fix auth type condition, rename span error message
Mar 19, 2025
724800c
Merge pull request #1 from miracum/fedoralina/basicAuth-gPAS-only
joundso Mar 24, 2025
08d07af
update config.json, hide epix and sap features
Apr 15, 2025
5e31076
init 2 domains logic, logic for settings branching in index file
Apr 28, 2025
2762fdb
allow 9 digits input, add logic for check digit validation
May 13, 2025
07bcd4c
Update readme and add test cases for basic auth
May 19, 2025
fc3aec5
allow subdirectory for authentication url
cerhardt Mar 20, 2025
01969e7
Merge branch 'cerhardt:master' into fedoralina/test
fedoralina May 26, 2025
41d0884
update readme with system config examples
May 27, 2025
9617479
Merge pull request #2 from miracum/fedoralina/test
fedoralina May 28, 2025
ff20dbe
store 10 digit ID instead of 9 digits in gpas_only mode
Jun 3, 2025
d33deeb
add more user-friendly information
Jun 3, 2025
59d7cce
Merge pull request #3 from miracum/fedoralina/ui-changes
fedoralina Jun 4, 2025
00d6db9
formal fixes
Jun 11, 2025
6150466
remove dummy logic for usage of multiple domains
Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions CheckDigit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
namespace meDIC\PseudoService;

class CheckDigit extends PseudoService {

/**
* Validation check digit of Pat ID
* 10 and 9 digits cases are considered
* 10 digits: returns input if calculated check digit match the input check digit
* 9 digits: append a calculated check digit after the input Pat-ID
* edge cases are avoided through live form validation in the index.php
*
* @author Egidia Cenko
* @param string $known_id patient ID
* @access public
* @return string known_id / -1
*/
public static function validateID($known_id){
// calculate check digit for Pat-ID
$calculatedCheckDigit = CheckDigit::calculateCheckDigit($known_id);

if (strlen($known_id) === 10) {
// compare calculated check digit with check digit from user input
$checkDigit = substr($known_id, -1);

// check digit correct?
if (intval($checkDigit) === $calculatedCheckDigit) {
// user input for Pat-ID is returned
return $known_id;
} else {
return -1;
}
} elseif (strlen($known_id) === 9) {
// return input Pat-ID with calculated check sum digit - no further check can be done
return $known_id . $calculatedCheckDigit;
}
}


/**
* Calculation of the check digit based on DIN ISO 7064
* 10 digits: remove the check digit, add a leading 0 for calculation
* 9 digits: add a leading 0 for calculation
*
* @author Egidia Cenko
* @param string $known_id patient ID
* @access public
* @return integer $checkDigit
*/
public static function calculateCheckDigit($known_id){
$digits = str_split($known_id);

if (strlen($known_id) === 10) {
// add leading 0 to digit, remove original input check digit for calculation
array_unshift($digits, "0");
$digits = array_slice($digits, 0, -1);
} elseif (strlen($known_id) === 9) {
// add leading zero to 9-digits input
array_unshift($digits, "0");
}

if (count($digits) !== 10) {
throw new \Exception(strtoupper("Length mismatch after processing: ") . implode($digits));
}

// logic for check digit acc. to DIN ISO 7064
$P = 10;
foreach ($digits as $char) {
$P += intval($char);
if ($P > 10) $P -= 10;
$P *= 2;
if ($P >= 11) $P -= 11;
}

$checkDigit = 11 - $P;
return $checkDigit === 10 ? 0 : $checkDigit;
}
}
Loading