-
Notifications
You must be signed in to change notification settings - Fork 7
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 #7 from cqframework/support-urns-urls-oids
Support URNs, URLs, and OIDs
- Loading branch information
Showing
6 changed files
with
409 additions
and
92 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
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,23 @@ | ||
/** | ||
* Extracts just the oid from a urn, url, or oid. If it is not a valid urn or VSAC URL, | ||
* it is assumed to be an oid and returned as-is. | ||
* @param {string} id - the urn, url, or oid | ||
* @returns {string} the oid | ||
*/ | ||
function extractOidAndVersion(id) { | ||
if (id == null) return []; | ||
|
||
// first check for VSAC FHIR URL (ideally https is preferred but support http just in case) | ||
// if there is a | at the end, it indicates that a version string follows | ||
let m = id.match(/^https?:\/\/cts\.nlm\.nih\.gov\/fhir\/ValueSet\/([^|]+)(\|(.+))?$/); | ||
if (m) return m[3] == null ? [m[1]] : [m[1], m[3]]; | ||
|
||
// then check for urn:oid | ||
m = id.match(/^urn:oid:(.+)$/); | ||
if (m) return [m[1]]; | ||
|
||
// finally just return as-is | ||
return [id]; | ||
} | ||
|
||
module.exports = extractOidAndVersion; |
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.