Produced by Araxis Merge on 12/5/2017 12:06:43 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCommon\main\src\java\gov\va\med\imaging | ImageURN.java | Mon Dec 4 21:34:24 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCommon\main\src\java\gov\va\med\imaging | ImageURN.java | Mon Dec 4 22:01:56 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1596 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.med.i maging; | |
| 2 | ||
| 3 | import gov .va.med.*; | |
| 4 | import gov .va.med.ex ceptions.G lobalArtif actIdentif ierFormatE xception; | |
| 5 | import gov .va.med.im aging.exce ptions.Ima geURNForma tException ; | |
| 6 | import gov .va.med.im aging.exce ptions.URN FormatExce ption; | |
| 7 | import gov .va.med.im aging.exch ange.utili ty.Base32C onversionU tility; | |
| 8 | import jav a.io.Seria lizable; | |
| 9 | import org .apache.lo gging.log4 j.LogManag er; | |
| 10 | import org .apache.lo gging.log4 j.Logger; | |
| 11 | import jav a.util.reg ex.Matcher ; | |
| 12 | import jav a.util.reg ex.Pattern ; | |
| 13 | ||
| 14 | /** | |
| 15 | * | |
| 16 | * @author
|
|
| 17 | * | |
| 18 | * Defines the synta x of a URN used to i dentify VA images to the outsi de world. | |
| 19 | * An Imag eURN is de fined to b e in the f ollowing f ormat: | |
| 20 | * "urn" + ":" + "va image" + " :" + <site -id> + "-" + <assign ed-id> + " -" + <stud yId> + "-" + <patien tId> [+ "- " + <modal ity>] | |
| 21 | * where: | |
| 22 | * <site -id> is ei ther the s ite from w hich the i mage origi nated or t he string "va-imagin g" | |
| 23 | * <assi gned-id> i s the perm anent, imm utable ID as assigne d by the o riginating site or a | |
| 24 | * VA-do main uniqu e ID (an I maging GUI D). | |
| 25 | * <stud yId> is th e study IE N in VistA | |
| 26 | * <imag eIcn> is t he unique VA identif ier for th e patient | |
| 27 | * <moda lity> is t he modalit y of the i mage | |
| 28 | * | |
| 29 | * notes: | |
| 30 | * Exter nally, the site-id s hould not be interpr eted as a location c omponent. It should be | |
| 31 | * inter preted as no more th an a speci fier in a GUID (i.e. just a co mponent th at restric ts | |
| 32 | * the r equired do main of un iqueness). Initiall y and inte rnally to the VA onl y, it may | |
| 33 | * be us ed as a lo cation hin t. Extern al code th at relies on the sit e ID as a location | |
| 34 | * may c ease funct ioning wit hout warni ng. | |
| 35 | * | |
| 36 | * Image URN follow s the synt ax of a UR N as defin ed in W3C RFC2141 wi th the fol lowing add itional | |
| 37 | * rules on the na mespace sp ecific str ing: | |
| 38 | * The c haracter ' -' is a re served cha racter, us ed to deli mit portio ns of the namespace | |
| 39 | * speci fic string . Specifi cally it i s used to delimit th e originat ing site I D from the | |
| 40 | * site- assigned i mage ID. | |
| 41 | * The n amespace s pecific st ring must consist of uppercase , lowercas e and nume ric charac ters | |
| 42 | * with a '-' some where in t he middle. | |
| 43 | * | |
| 44 | * @see http://www .ietf.org/ rfc/rfc214 1.txt | |
| 45 | * | |
| 46 | * NOTE: b oth this c lass and D ocumentURN MUST impl ement Glob alArtifact Identifier | |
| 47 | * | |
| 48 | */ | |
| 49 | @URNType(n amespace=" vaimage") | |
| 50 | public cla ss ImageUR N | |
| 51 | extends Ab stractImag ingURN | |
| 52 | implements Serializa ble, Globa lArtifactI dentifier | |
| 53 | { | |
| 54 | ||
| 55 | pr ivate stat ic final l ong serial VersionUID = -761672 3084757942 356L; | |
| 56 | pr ivate stat ic final S tring NAME SPACE = "v aimage"; | |
| 57 | pu blic stati c final We llKnownOID DEFAULT_H OME_COMMUN ITY_ID = W ellKnownOI D.VA_RADIO LOGY_IMAGE ; | |
| 58 | ||
| 59 | pr ivate stat ic Namespa ceIdentifi er namespa ceIdentifi er = null; | |
| 60 | pu blic stati c synchron ized Names paceIdenti fier getMa nagedNames pace() | |
| 61 | { | |
| 62 | if(n amespaceId entifier = = null) | |
| 63 | namesp aceIdentif ier = new NamespaceI dentifier( NAMESPACE) ; | |
| 64 | retu rn namespa ceIdentifi er; | |
| 65 | } | |
| 66 | ||
| 67 | // the addit ional plus '+' makes the compo nent regul ar express ions into possessive quantifie rs | |
| 68 | // and there by improve s performa nce (to th e point of usability ) | |
| 69 | // see http: //www.regu lar-expres sions.info /possessiv e.html for an explan ation | |
| 70 | pr ivate stat ic final S tring name spaceSpeci ficStringR egex = | |
| 71 | "([^ -]+)" + // the site ID | |
| 72 | URN. namespaceS pecificStr ingDelimit er + | |
| 73 | "([^ -]+)" + // t he image I D | |
| 74 | URN. namespaceS pecificStr ingDelimit er + | |
| 75 | "([^ -]+)" + // t he group o r study ID | |
| 76 | URN. namespaceS pecificStr ingDelimit er + | |
| 77 | "([^ -]+)" + // t he patient ID | |
| 78 | "(?: " + URN.na mespaceSpe cificStrin gDelimiter + ")?" + | |
| 79 | "([^ -]+)?"; // t he optiona l modality | |
| 80 | pr ivate stat ic final P attern nam espaceSpec ificString Pattern = Pattern.co mpile(name spaceSpeci ficStringR egex); | |
| 81 | pr otected st atic final int SITE_ ID_GROUP = 1; | |
| 82 | pr otected st atic final int INSTA NCE_ID_GRO UP = 2; | |
| 83 | pr otected st atic final int GROUP _ID_GROUP = 3; | |
| 84 | pr otected st atic final int PATIE NT_ID_GROU P = 4; | |
| 85 | pr ivate stat ic final i nt MODALIT Y_GROUP = 5; | |
| 86 | ||
| 87 | pu blic stati c final in t ADDITION AL_IDENTIF IER_PATIEN T_IDENTIFI ER_TYPE_IN DEX = 0; | |
| 88 | ||
| 89 | st atic | |
| 90 | { | |
| 91 | Syst em.out.pri ntln("Imag eURN NSS r egular exp ression is '" + name spaceSpeci ficStringR egex + "'. "); | |
| 92 | } | |
| 93 | ||
| 94 | pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Imag eURN.class ); | |
| 95 | ||
| 96 | /* * | |
| 97 | * | |
| 98 | * @param or iginatingS iteId - if the site ID is '200 ' then the returned instance w ill be | |
| 99 | * a BhieImageU RN | |
| 100 | * @param as signedId | |
| 101 | * @param st udyId | |
| 102 | * @param pa tientIcn | |
| 103 | * @return | |
| 104 | * @throws U RNFormatEx ception | |
| 105 | * / | |
| 106 | pu blic stati c ImageURN create( | |
| 107 | Stri ng origina tingSiteId , | |
| 108 | Stri ng assigne dId, | |
| 109 | Stri ng studyId , | |
| 110 | Stri ng patient Icn) | |
| 111 | th rows URNFo rmatExcept ion | |
| 112 | { | |
| 113 | if(B hieImageUR N.DEFAULT_ REPOSITORY _ID.equals (originati ngSiteId)) | |
| 114 | return BhieImage URN.create (assignedI d, studyId , patientI cn); | |
| 115 | else | |
| 116 | return create(or iginatingS iteId, ass ignedId, s tudyId, pa tientIcn, null); | |
| 117 | } | |
| 118 | ||
| 119 | /* * | |
| 120 | * | |
| 121 | * @param or iginatingS iteId - if the site ID is '200 ' then the returned instance w ill be | |
| 122 | * a BhieImageU RN | |
| 123 | * @param as signedId | |
| 124 | * @param st udyId | |
| 125 | * @param pa tientIcn | |
| 126 | * @param im ageModalit y | |
| 127 | * @return | |
| 128 | * @throws I mageURNFor matExcepti on | |
| 129 | * / | |
| 130 | pu blic stati c ImageURN create( | |
| 131 | Stri ng origina tingSiteId , | |
| 132 | Stri ng assigne dId, | |
| 133 | Stri ng studyId , | |
| 134 | Stri ng patient Icn, | |
| 135 | Stri ng imageMo dality) | |
| 136 | th rows URNFo rmatExcept ion | |
| 137 | { | |
| 138 | if(B hieImageUR N.DEFAULT_ REPOSITORY _ID.equals (originati ngSiteId)) | |
| 139 | return BhieImage URN.create (originati ngSiteId, assignedId , studyId, patientIc n, imageMo dality); | |
| 140 | else | |
| 141 | return new Image URN(origin atingSiteI d, assigne dId, study Id, patien tIcn, imag eModality) ; | |
| 142 | } | |
| 143 | ||
| 144 | ||
| 145 | /* * | |
| 146 | * Create a DocumentUR N instance from an I mageURN. | |
| 147 | * This prov ide the tr anslation within the datasourc e, using t he same | |
| 148 | * RPCs as i mage retri eval and p resenting results in Document semantics. | |
| 149 | * @param do cumentUrn | |
| 150 | * @return | |
| 151 | * @throws U RNFormatEx ception | |
| 152 | * / | |
| 153 | pu blic stati c ImageURN create(Do cumentURN documentUr n) | |
| 154 | th rows URNFo rmatExcept ion | |
| 155 | { | |
| 156 | retu rn create( | |
| 157 | docume ntUrn.getO riginating SiteId(), | |
| 158 | docume ntUrn.getD ocumentId( ), | |
| 159 | docume ntUrn.getD ocumentSet Id(), | |
| 160 | docume ntUrn.getP atientId() | |
| 161 | ); | |
| 162 | } | |
| 163 | ||
| 164 | /* * | |
| 165 | * | |
| 166 | * @param ur nComponent s | |
| 167 | * @return | |
| 168 | * @throws U RNFormatEx ception | |
| 169 | * / | |
| 170 | pu blic stati c ImageURN create(UR NComponent s urnCompo nents, SER IALIZATION _FORMAT se rializatio nFormat) | |
| 171 | th rows URNFo rmatExcept ion | |
| 172 | { | |
| 173 | Imag eURN image Urn = null ; | |
| 174 | ||
| 175 | // i f this pro bably a BH IE Image U RN | |
| 176 | if( BhieImageU RN.getMana gedNamespa ce().equal s(urnCompo nents.getN amespaceId entifier() ) || | |
| 177 | (Image URN.getMan agedNamesp ace().equa ls(urnComp onents.get NamespaceI dentifier( )) && | |
| 178 | urnCo mponents.g etNamespac eSpecificS tring().st artsWith(B hieImageUR N.DEFAULT_ REPOSITORY _ID + URN. namespaceS pecificStr ingDelimit er)) | |
| 179 | ) | |
| 180 | { | |
| 181 | imageU rn = Bhie ImageURN.c reate(urnC omponents, serializa tionFormat ); | |
| 182 | } | |
| 183 | else | |
| 184 | { | |
| 185 | imageU rn = new I mageURN(ur nComponent s, seriali zationForm at); | |
| 186 | ||
| 187 | // JMW 1/3/13 P1 30 - Image URNs can n ow contain additiona l identifi ers to hol d the Pati entIdentif ierType | |
| 188 | //if(u rnComponen ts.getAddi tionalIden tifers() ! = null && urnCompone nts.getAdd itionalIde ntifers(). length > 0 ) | |
| 189 | // throw ne w URNForma tException ("The urn components include a dditional identifier s, which i s not vali d for an I mageURN.") ; | |
| 190 | ||
| 191 | ||
| 192 | // Mos t of the t ime a Bhie ImageURN w ill fail t o parse co rrectly wh en treated as an Ima geURN | |
| 193 | // and an except ion will b e thrown a lready. | |
| 194 | // On the off ch ance that does not h appen then this will catch it | |
| 195 | if( Bh ieImageURN .DEFAULT_R EPOSITORY_ ID.equals( imageUrn.g etOriginat ingSiteId( )) ) | |
| 196 | imageUrn = BhieIm ageURN.cre ate(urnCom ponents, s erializati onFormat); | |
| 197 | } | |
| 198 | retu rn imageUr n; | |
| 199 | } | |
| 200 | ||
| 201 | ||
| 202 | /* * | |
| 203 | * | |
| 204 | * / | |
| 205 | pu blic stati c ImageURN createFro mGlobalArt ifactIdent ifiers( | |
| 206 | Stri ng homeCom munityId, | |
| 207 | Stri ng reposit oryId, | |
| 208 | Stri ng documen tId) | |
| 209 | th rows URNFo rmatExcept ion | |
| 210 | { | |
| 211 | retu rn createF romGlobalA rtifactIde ntifiers( homeCommun ityId, rep ositoryId, documentI d, (String [])null); | |
| 212 | } | |
| 213 | ||
| 214 | /* * | |
| 215 | * | |
| 216 | * @param ho meCommunit yId | |
| 217 | * @param re positoryId | |
| 218 | * @param do cumentId | |
| 219 | * @return | |
| 220 | * @throws U RNFormatEx ception | |
| 221 | * / | |
| 222 | pu blic stati c ImageURN createFro mGlobalArt ifactIdent ifiers( | |
| 223 | Stri ng homeCom munityId, | |
| 224 | Stri ng reposit oryId, | |
| 225 | Stri ng documen tId, | |
| 226 | Stri ng... addi tionalIden tifiers) | |
| 227 | th rows URNFo rmatExcept ion | |
| 228 | { | |
| 229 | if( BhieImageU RN.isAppli cableHomeC ommunityId (homeCommu nityId, re positoryId , document Id) ) | |
| 230 | return BhieImage URN.create FromGlobal ArtifactId entifiers( homeCommun ityId, rep ositoryId, documentI d); | |
| 231 | else if( Image URN.isAppl icableHome CommunityI d(homeComm unityId, r epositoryI d, documen tId) ) | |
| 232 | return new Image URN( repos itoryId, d ocumentId ); | |
| 233 | else | |
| 234 | throw new URNFor matExcepti on("Home c ommunity I D '" + hom eCommunity Id + "' ca nnot be us ed to crea te an Imag eURN or it s derivati ves."); | |
| 235 | } | |
| 236 | ||
| 237 | /* * | |
| 238 | * Required static met hod, must return TRU E when thi s class ca n represen t | |
| 239 | * a global artifact I D with the given hom e communit y ID. | |
| 240 | * | |
| 241 | * @param ho meCommunit yId | |
| 242 | * @param re positoryId | |
| 243 | * @param do cumentId | |
| 244 | * @return | |
| 245 | * / | |
| 246 | pu blic stati c boolean isApplicab leHomeComm unityId(St ring homeC ommunityId , String r epositoryI d, String documentId ) | |
| 247 | { | |
| 248 | retu rn | |
| 249 | ImageU RN.NAMESPA CE.equalsI gnoreCase( homeCommun ityId) || | |
| 250 | WellKn ownOID.VA_ RADIOLOGY_ IMAGE.isAp plicable(h omeCommuni tyId); | |
| 251 | } | |
| 252 | ||
| 253 | ||
| 254 | pu blic stati c Matcher getNamespa ceSpecific StringMatc her(CharSe quence inp ut) | |
| 255 | { | |
| 256 | retu rn ImageUR N.namespac eSpecificS tringPatte rn.matcher (input); | |
| 257 | } | |
| 258 | ||
| 259 | // ========= ========== ========== ========== ========== ========== ========== ========== ======== | |
| 260 | // Instance Members | |
| 261 | // ========= ========== ========== ========== ========== ========== ========== ========== ======== | |
| 262 | pr otected St ring origi natingSite Id; | |
| 263 | pr otected St ring insta nceId; | |
| 264 | pr otected St ring group Id; | |
| 265 | pr otected St ring patie ntId; | |
| 266 | pr otected St ring image Modality; | |
| 267 | ||
| 268 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== | |
| 269 | // Instance Constructo rs | |
| 270 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== | |
| 271 | ||
| 272 | /* * | |
| 273 | * Provided only as a pass throu gh for der ived class es. | |
| 274 | * | |
| 275 | * @param ni d | |
| 276 | * @throws U RNFormatEx ception | |
| 277 | * / | |
| 278 | pr otected Im ageURN(Nam espaceIden tifier nid ) | |
| 279 | th rows URNFo rmatExcept ion | |
| 280 | { | |
| 281 | supe r(nid); | |
| 282 | } | |
| 283 | ||
| 284 | /* * | |
| 285 | * Provided only as a pass throu gh for der ived class es. | |
| 286 | * | |
| 287 | * / | |
| 288 | pr otected Im ageURN( | |
| 289 | Name spaceIdent ifier name spaceIdent ifier, | |
| 290 | Stri ng namespa ceSpecific String, | |
| 291 | Stri ng... addi tionalIden tifiers) | |
| 292 | th rows URNFo rmatExcept ion | |
| 293 | { | |
| 294 | supe r(namespac eIdentifie r, namespa ceSpecific String, ad ditionalId entifiers) ; | |
| 295 | } | |
| 296 | ||
| 297 | /* * | |
| 298 | * Used dire ctly and a pass thro ugh for de rived clas ses. | |
| 299 | * The const ructor cal led by the URN class when a UR N derived class | |
| 300 | * is being created fr om a Strin g represen tation. | |
| 301 | * | |
| 302 | * @param co mponents | |
| 303 | * @throws U RNFormatEx ception | |
| 304 | * / | |
| 305 | pr otected Im ageURN(URN Components urnCompon ents, SERI ALIZATION_ FORMAT ser ialFormat) | |
| 306 | th rows URNFo rmatExcept ion | |
| 307 | { | |
| 308 | supe r(urnCompo nents, ser ialFormat) ; | |
| 309 | } | |
| 310 | ||
| 311 | /* * | |
| 312 | * | |
| 313 | * @param or iginatingS iteId | |
| 314 | * @param im ageId | |
| 315 | * @param st udyId | |
| 316 | * @param pa tientIcn | |
| 317 | * @param im ageModalit y | |
| 318 | * @throws U RNFormatEx ception | |
| 319 | * / | |
| 320 | pr ivate Imag eURN( | |
| 321 | Stri ng origina tingSiteId , | |
| 322 | Stri ng assigne dId, | |
| 323 | Stri ng studyId , | |
| 324 | Stri ng patient Id, | |
| 325 | Stri ng imageMo dality) | |
| 326 | th rows URNFo rmatExcept ion | |
| 327 | { | |
| 328 | supe r(ImageURN .getManage dNamespace ()); | |
| 329 | ||
| 330 | orig inatingSit eId = URN. RFC2141_ES CAPING.esc apeIllegal Characters (originati ngSiteId); | |
| 331 | assi gnedId = U RN.RFC2141 _ESCAPING. escapeIlle galCharact ers(assign edId); | |
| 332 | stud yId = URN. RFC2141_ES CAPING.esc apeIllegal Characters (studyId); | |
| 333 | pati entId = UR N.RFC2141_ ESCAPING.e scapeIlleg alCharacte rs(patient Id); | |
| 334 | imag eModality = URN.RFC2 141_ESCAPI NG.escapeI llegalChar acters(ima geModality ); | |
| 335 | ||
| 336 | if( !AbstractI magingURN. siteIdPatt ern.matche r(originat ingSiteId) .matches() ) | |
| 337 | throw new URNFor matExcepti on("The si te ID '" + originati ngSiteId + "' does n ot match t he pattern '" + Abst ractImagin gURN.siteI dPattern.p attern()); | |
| 338 | this .originati ngSiteId = originati ngSiteId; | |
| 339 | ||
| 340 | if( !AbstractI magingURN. imageIdPat tern.match er(assigne dId).match es() ) | |
| 341 | throw new URNFor matExcepti on("The im age ID '" + assigned Id + "' do es not mat ch the pat tern '" + AbstractIm agingURN.i mageIdPatt ern.patter n()); | |
| 342 | this .instanceI d = assign edId; | |
| 343 | ||
| 344 | if( !AbstractI magingURN. groupIdPat tern.match er(studyId ).matches( ) ) | |
| 345 | throw new URNFor matExcepti on("The gr oup ID '" + studyId + "' does not match the patter n '" + Abs tractImagi ngURN.grou pIdPattern .pattern() ); | |
| 346 | this .groupId = studyId; | |
| 347 | ||
| 348 | if( !AbstractI magingURN. patientIdP attern.mat cher(patie ntId).matc hes() ) | |
| 349 | throw new URNFor matExcepti on("The pa tient ID ' " + patien tId + "' d oes not ma tch the pa ttern '" + AbstractI magingURN. patientIdP attern.pat tern()); | |
| 350 | this .patientId = patient Id; | |
| 351 | ||
| 352 | if(i mageModali ty != null && imageM odality.le ngth() <= 0) | |
| 353 | imageM odality = null; | |
| 354 | if( imageModal ity != nul l && !Abst ractImagin gURN.modal ityPattern .matcher(i mageModali ty).matche s() ) | |
| 355 | throw new URNFor matExcepti on("The mo dality '" + imageMod ality + "' does not match the pattern '" + Abstrac tImagingUR N.modality Pattern.pa ttern()); | |
| 356 | ||
| 357 | this .imageModa lity = ima geModality ; | |
| 358 | } | |
| 359 | ||
| 360 | /* * | |
| 361 | * Construct or from th e GAI (IHE ) identifi ers | |
| 362 | * | |
| 363 | * @param re positoryUn iqueId | |
| 364 | * @param do cumentId | |
| 365 | * @throws U RNFormatEx ception | |
| 366 | * / | |
| 367 | pr ivate Imag eURN(Strin g reposito ryUniqueId , String a ssignedId) | |
| 368 | th rows URNFo rmatExcept ion | |
| 369 | { | |
| 370 | supe r(ImageURN .getManage dNamespace ()); | |
| 371 | repo sitoryUniq ueId = URN .RFC2141_E SCAPING.es capeIllega lCharacter s(reposito ryUniqueId ); | |
| 372 | assi gnedId = U RN.RFC2141 _ESCAPING. escapeIlle galCharact ers(assign edId); | |
| 373 | ||
| 374 | try | |
| 375 | { | |
| 376 | parseD ocumentUni queIdIntoF ields(assi gnedId); | |
| 377 | this.o riginating SiteId = r epositoryU niqueId; | |
| 378 | } | |
| 379 | catc h (GlobalA rtifactIde ntifierFor matExcepti on x) | |
| 380 | { | |
| 381 | throw new URNFor matExcepti on(x); | |
| 382 | } | |
| 383 | } | |
| 384 | ||
| 385 | /* * | |
| 386 | * Override the do-not hing versi on of this method to parse the | |
| 387 | * namespace specific portion an d find the component parts. | |
| 388 | * | |
| 389 | * @param na mespaceSpe cificStrin g | |
| 390 | * @throws I mageURNFor matExcepti on | |
| 391 | * / | |
| 392 | @O verride | |
| 393 | pu blic void parseNames paceSpecif icString(N amespaceId entifier n amespace, String nam espaceSpec ificString , SERIALIZ ATION_FORM AT seriali zationForm at) | |
| 394 | th rows URNFo rmatExcept ion | |
| 395 | { | |
| 396 | if(n amespaceSp ecificStri ng == null ) | |
| 397 | throw new URNFor matExcepti on("The na mespace sp ecific str ing for a( n) " + thi s.getClass ().getSimp leName() + " cannot be null.") ; | |
| 398 | ||
| 399 | Matc her nssMat cher = nam espaceSpec ificString Pattern.ma tcher(name spaceSpeci ficString) ; | |
| 400 | ||
| 401 | if(! nssMatche r.matches( )) | |
| 402 | { | |
| 403 | String msg = "Na mespace sp ecific str ing '" + n amespaceSp ecificStri ng + "' is not valid ."; | |
| 404 | logger .warn(msg) ; | |
| 405 | throw new ImageU RNFormatEx ception(ms g); | |
| 406 | } | |
| 407 | ||
| 408 | this .originati ngSiteId = nssMatche r.group(SI TE_ID_GROU P).trim(); | |
| 409 | Stri ng tmpInst anceId = n ssMatcher. group(INST ANCE_ID_GR OUP).trim( ); | |
| 410 | Stri ng tmpGrou pId = nssM atcher.gro up(GROUP_I D_GROUP).t rim(); | |
| 411 | ||
| 412 | swit ch(seriali zationForm at) | |
| 413 | { | |
| 414 | case PATCH83_V FTP: | |
| 415 | setGro upId( Base 32Conversi onUtility. base32Deco de(tmpGrou pId) ); | |
| 416 | setIns tanceId( B ase32Conve rsionUtili ty.base32D ecode(tmpI nstanceId) ); | |
| 417 | break; | |
| 418 | case RFC2141: | |
| 419 | this.g roupId = t mpGroupId; | |
| 420 | this.i nstanceId = tmpInsta nceId; | |
| 421 | break; | |
| 422 | case VFTP: | |
| 423 | this.g roupId = t mpGroupId; | |
| 424 | this.i nstanceId = tmpInsta nceId; | |
| 425 | break; | |
| 426 | case RAW: | |
| 427 | this.g roupId = t mpGroupId; | |
| 428 | this.i nstanceId = tmpInsta nceId; | |
| 429 | break; | |
| 430 | case CDTP: | |
| 431 | this.g roupId = U RN.FILENAM E_TO_RFC21 41_ESCAPIN G.escapeIl legalChara cters(tmpG roupId); | |
| 432 | this.i nstanceId = URN.FILE NAME_TO_RF C2141_ESCA PING.escap eIllegalCh aracters(t mpInstance Id); | |
| 433 | break; | |
| 434 | case NATIVE: | |
| 435 | setGro upId(tmpGr oupId); | |
| 436 | setIns tanceId(tm pInstanceI d); | |
| 437 | break; | |
| 438 | } | |
| 439 | ||
| 440 | this .patientId = URN.RFC 2141_ESCAP ING.escape IllegalCha racters( n ssMatcher. group(PATI ENT_ID_GRO UP).trim() ); | |
| 441 | if(n ssMatcher. group(MODA LITY_GROUP ) != null) | |
| 442 | this.i mageModali ty = URN.R FC2141_ESC APING.esca peIllegalC haracters( | |
| 443 | nssMatch er.group(M ODALITY_GR OUP).trim( ).length() > 0 ? nss Matcher.gr oup(MODALI TY_GROUP). trim() : n ull ); | |
| 444 | else | |
| 445 | this.i mageModali ty = null; | |
| 446 | } | |
| 447 | ||
| 448 | @O verride | |
| 449 | pu blic Strin g getHomeC ommunityId () | |
| 450 | { | |
| 451 | // I mages are always in the VA com munity | |
| 452 | retu rn WellKno wnOID.VA_R ADIOLOGY_I MAGE.getCa nonicalVal ue().toStr ing(); | |
| 453 | } | |
| 454 | ||
| 455 | @O verride | |
| 456 | pu blic Names paceIdenti fier getNa mespaceIde ntifier() | |
| 457 | { | |
| 458 | retu rn ImageUR N.getManag edNamespac e(); | |
| 459 | } | |
| 460 | ||
| 461 | @O verride | |
| 462 | pu blic Strin g getOrigi natingSite Id() | |
| 463 | { | |
| 464 | retu rn this.or iginatingS iteId; | |
| 465 | } | |
| 466 | ||
| 467 | pu blic Strin g getImage Id(){retur n this.get InstanceId ();} | |
| 468 | pu blic Strin g getInsta nceId() | |
| 469 | { | |
| 470 | retu rn RFC2141 _ESCAPING. unescapeIl legalChara cters(this .instanceI d); | |
| 471 | } | |
| 472 | ||
| 473 | pu blic void setInstanc eId(String instanceI d) | |
| 474 | { | |
| 475 | this .instanceI d = RFC214 1_ESCAPING .escapeIll egalCharac ters(insta nceId); | |
| 476 | } | |
| 477 | ||
| 478 | pu blic Strin g getStudy Id(){retur n getGroup Id();} | |
| 479 | /* * | |
| 480 | * The study ID may ha ve escape sequences in it if t hey were i ncluded | |
| 481 | * in the st ring from which the URN was co nstructed. | |
| 482 | * Unescape the string to get th e original value. | |
| 483 | * | |
| 484 | * @return | |
| 485 | * / | |
| 486 | pu blic Strin g getGroup Id() | |
| 487 | { | |
| 488 | retu rn this.gr oupId == n ull ? null : URN.RFC 2141_ESCAP ING.unesca peIllegalC haracters( this.group Id); | |
| 489 | } | |
| 490 | pu blic void setStudyId (String gr oupId){set GroupId(gr oupId);} | |
| 491 | pu blic void setGroupId (String gr oupId) | |
| 492 | { | |
| 493 | this .groupId = RFC2141_E SCAPING.es capeIllega lCharacter s(groupId) ; | |
| 494 | } | |
| 495 | ||
| 496 | @O verride | |
| 497 | pu blic Strin g getPatie ntId() | |
| 498 | { | |
| 499 | retu rn RFC2141 _ESCAPING. unescapeIl legalChara cters(this .patientId ); | |
| 500 | } | |
| 501 | ||
| 502 | pu blic void setPatient Id(String patientId) | |
| 503 | { | |
| 504 | this .patientId = RFC2141 _ESCAPING. escapeIlle galCharact ers(patien tId); | |
| 505 | } | |
| 506 | ||
| 507 | pu blic Strin g getImage Modality() | |
| 508 | { | |
| 509 | retu rn this.im ageModalit y == null ? null : R FC2141_ESC APING.unes capeIllega lCharacter s(this.ima geModality ); | |
| 510 | } | |
| 511 | pu blic void setImageMo dality(Str ing imageM odality) | |
| 512 | { | |
| 513 | this .imageModa lity = RFC 2141_ESCAP ING.escape IllegalCha racters(im ageModalit y); | |
| 514 | } | |
| 515 | ||
| 516 | // ========= ========== ========== ========== ========== ========== ========== ====== | |
| 517 | // Generated hashCode( ) and equa ls(), the modality s hould not be include d | |
| 518 | // in the co mparison. | |
| 519 | // Modified equals() t o exclude super.equa ls() | |
| 520 | // ========= ========== ========== ========== ========== ========== ========== ====== | |
| 521 | ||
| 522 | /* * | |
| 523 | * | |
| 524 | * / | |
| 525 | @O verride | |
| 526 | pu blic int h ashCode() | |
| 527 | { | |
| 528 | fina l int prim e = 31; | |
| 529 | int result = s uper.hashC ode(); | |
| 530 | resu lt = prime * result + ((this.g roupId == null) ? 0 : this.gro upId.hashC ode()); | |
| 531 | resu lt = prime * result + ((this.i nstanceId == null) ? 0 : this. instanceId .hashCode( )); | |
| 532 | resu lt = prime * result + ((this.o riginating SiteId == null) ? 0 : this.ori ginatingSi teId.hashC ode()); | |
| 533 | resu lt = prime * result + ((this.p atientId = = null) ? 0 : this.p atientId.h ashCode()) ; | |
| 534 | retu rn result; | |
| 535 | } | |
| 536 | ||
| 537 | /* * | |
| 538 | * | |
| 539 | * Modi fied equal s() to exc lude super .equals() | |
| 540 | * / | |
| 541 | @O verride | |
| 542 | pu blic boole an equals( Object obj ) | |
| 543 | { | |
| 544 | if ( this == ob j) | |
| 545 | return true; | |
| 546 | if ( getClass() != obj.ge tClass()) | |
| 547 | return false; | |
| 548 | Imag eURN other = (ImageU RN) obj; | |
| 549 | if ( this.group Id == null ) | |
| 550 | { | |
| 551 | if (ot her.groupI d != null) | |
| 552 | return f alse; | |
| 553 | } | |
| 554 | else if (!this .groupId.e quals(othe r.groupId) ) | |
| 555 | return false; | |
| 556 | if ( this.insta nceId == n ull) | |
| 557 | { | |
| 558 | if (ot her.instan ceId != nu ll) | |
| 559 | return f alse; | |
| 560 | } | |
| 561 | else if (!this .instanceI d.equals(o ther.insta nceId)) | |
| 562 | return false; | |
| 563 | if ( this.origi natingSite Id == null ) | |
| 564 | { | |
| 565 | if (ot her.origin atingSiteI d != null) | |
| 566 | return f alse; | |
| 567 | } | |
| 568 | else if (!this .originati ngSiteId.e quals(othe r.originat ingSiteId) ) | |
| 569 | return false; | |
| 570 | if ( this.patie ntId == nu ll) | |
| 571 | { | |
| 572 | if (ot her.patien tId != nul l) | |
| 573 | return f alse; | |
| 574 | } | |
| 575 | else if (!this .patientId .equals(ot her.patien tId)) | |
| 576 | return false; | |
| 577 | retu rn true; | |
| 578 | } | |
| 579 | ||
| 580 | // ========= ========== ========== ========== ========== ========== ========== ====== | |
| 581 | // Serializa tion forma ts | |
| 582 | // ========= ========== ========== ========== ========== ========== ========== ====== | |
| 583 | ||
| 584 | /* * | |
| 585 | * Stringifi ed into th e Patch83 VFTP forma t, | |
| 586 | * i.e. urn: vaimage:20 0-<base32 encoded in stance ID> -<base32 e ncoded gro up ID>-<pa tient ICN> -<modality > | |
| 587 | * The insta nce ID and group ID are base 3 2 encoded, | |
| 588 | * the patie nt ICN and modality, if it exi sts, are n ot BASE32 encoded | |
| 589 | * the names pace is "v aimage" an d | |
| 590 | * the site ID is the originatin g site ID. | |
| 591 | * | |
| 592 | * @see gov. va.med.URN #toStringP atch83VFTP () | |
| 593 | * / | |
| 594 | @O verride | |
| 595 | pr otected St ring toStr ingPatch83 VFTP() | |
| 596 | { | |
| 597 | Stri ngBuilder ahnold = n ew StringB uilder(); | |
| 598 | ||
| 599 | // b uild the s cheme iden tifier | |
| 600 | ahno ld.append( urnSchemaI dentifier) ; | |
| 601 | ahno ld.append( urnCompone ntDelimite r); | |
| 602 | ||
| 603 | // b uild the n amespace i dentifier | |
| 604 | ahno ld.append( ImageURN.g etManagedN amespace() .toString( )); | |
| 605 | ahno ld.append( urnCompone ntDelimite r); | |
| 606 | ahno ld.append( getOrigina tingSiteId ()); | |
| 607 | ahno ld.append( URN.namesp aceSpecifi cStringDel imiter); | |
| 608 | ahno ld.append( SERIALIZA TION_FORMA T.PATCH83_ VFTP.seria lize(this. getInstanc eId()) ); | |
| 609 | ahno ld.append( URN.namesp aceSpecifi cStringDel imiter); | |
| 610 | ahno ld.append( SERIALIZA TION_FORMA T.PATCH83_ VFTP.seria lize(this. getGroupId ()) ); | |
| 611 | if(g etPatientI d() != nul l) | |
| 612 | { | |
| 613 | ahnold .append(UR N.namespac eSpecificS tringDelim iter); | |
| 614 | ahnold .append( g etPatientI d() ); | |
| 615 | } | |
| 616 | if(g etImageMod ality() != null && g etImageMod ality().le ngth() > 0 ) | |
| 617 | { | |
| 618 | ahnold .append(UR N.namespac eSpecificS tringDelim iter); | |
| 619 | ahnold .append( t his.getIma geModality () ); | |
| 620 | } | |
| 621 | retu rn ahnold. toString() ; | |
| 622 | } | |
| 623 | ||
| 624 | /* * | |
| 625 | * | |
| 626 | * / | |
| 627 | @O verride | |
| 628 | pu blic Strin g getNames paceSpecif icString(S ERIALIZATI ON_FORMAT serializat ionFormat) | |
| 629 | { | |
| 630 | seri alizationF ormat = se rializatio nFormat == null ? SE RIALIZATIO N_FORMAT.R FC2141 : s erializati onFormat; | |
| 631 | Stri ngBuilder ahnold = n ew StringB uilder(); | |
| 632 | ||
| 633 | // b uild the n amespace s pecific st ring | |
| 634 | ahno ld.append( this.getO riginating SiteId() ) ; | |
| 635 | ahno ld.append( URN.namesp aceSpecifi cStringDel imiter); | |
| 636 | ahno ld.append( this.getI nstanceId( ) ); | |
| 637 | ahno ld.append( URN.namesp aceSpecifi cStringDel imiter); | |
| 638 | ahno ld.append( serializa tionFormat .serialize (this.getG roupId()) ); | |
| 639 | ahno ld.append( URN.namesp aceSpecifi cStringDel imiter); | |
| 640 | ahno ld.append( this.getP atientId() ); | |
| 641 | if(g etImageMod ality() != null) // i f no modal ity, leave it off, n o "null" | |
| 642 | { | |
| 643 | ahnold .append(UR N.namespac eSpecificS tringDelim iter); | |
| 644 | ahnold .append(ge tImageModa lity()); | |
| 645 | } | |
| 646 | ||
| 647 | retu rn ahnold. toString() ; | |
| 648 | } | |
| 649 | ||
| 650 | // ========= ========== ========== ========== ========== ========== ========== ========== ====== | |
| 651 | // Global Ar tifact Ide ntifier Im plementati on | |
| 652 | // ========= ========== ========== ========== ========== ========== ========== ========== ====== | |
| 653 | ||
| 654 | /* * | |
| 655 | * A special implement ation of . equals() t his is use d with oth er | |
| 656 | * GlobalArt ifactIdent ifier real izations. | |
| 657 | * | |
| 658 | * @param th at | |
| 659 | * @return | |
| 660 | * / | |
| 661 | pu blic boole an equalsG lobalArtif actIdentif ier(Global ArtifactId entifier t hat) | |
| 662 | { | |
| 663 | retu rn GlobalA rtifactIde ntifierImp l.equalsGl obalArtifa ctIdentifi er(this, t hat); | |
| 664 | } | |
| 665 | ||
| 666 | @O verride | |
| 667 | pu blic boole an isEquiv alent(Rout ingToken t hat) | |
| 668 | { | |
| 669 | retu rn Routing TokenImpl. isEquivale nt(this, t hat); | |
| 670 | } | |
| 671 | ||
| 672 | @O verride | |
| 673 | pu blic boole an isInclu ding(Routi ngToken th at) | |
| 674 | { | |
| 675 | retu rn Routing TokenImpl. isIncludin g(this, th at); | |
| 676 | } | |
| 677 | ||
| 678 | // formattin g of the d ocument un ique ID, u sed for Gl obalArtifa ctIdentifi er support | |
| 679 | pr ivate stat ic final S tring docu mentUnique IdRegex = | |
| 680 | "(" + IMAGEID_ REGEX + ") " + | |
| 681 | URN. namespaceS pecificStr ingDelimit er + | |
| 682 | "(" + GROUPID_ REGEX + ") " + | |
| 683 | URN. namespaceS pecificStr ingDelimit er + | |
| 684 | "(" + PATIENTI D_REGEX + ")"; | |
| 685 | pr ivate stat ic final P attern doc umentUniqu eIdPattern = Pattern .compile(d ocumentUni queIdRegex ); | |
| 686 | pr ivate stat ic final i nt DOCUMEN TUNIQUEID_ DOCUMENT_I D_GROUP = 1; | |
| 687 | pr ivate stat ic final i nt DOCUMEN TUNIQUEID_ GROUP_ID_G ROUP = 3; | |
| 688 | pr ivate stat ic final i nt DOCUMEN TUNIQUEID_ PATIENT_ID _GROUP = 5 ; | |
| 689 | ||
| 690 | @O verride | |
| 691 | pu blic Strin g getDocum entUniqueI d() | |
| 692 | { | |
| 693 | retu rn buildDo cumentUniq ueId( getI nstanceId( ), getStud yId(), get PatientId( ) ); | |
| 694 | } | |
| 695 | ||
| 696 | pr ivate void parseDocu mentUnique IdIntoFiel ds(String documentId ) | |
| 697 | th rows Globa lArtifactI dentifierF ormatExcep tion | |
| 698 | { | |
| 699 | Stri ng[] compo nents = pa rseDocumen tUniqueId( documentId ); | |
| 700 | inst anceId = c omponents[ 0]; | |
| 701 | grou pId = comp onents[1]; | |
| 702 | pati entId = co mponents[2 ]; | |
| 703 | } | |
| 704 | ||
| 705 | /* * | |
| 706 | * This meth od and par seUniqueId () are dec lared stat ic to make testing e asier. | |
| 707 | * These two methods a re reflexi ve, so par seUniqueID ( buildDoc umentUniqu eId(A,B,C) ) = {A,B, C} | |
| 708 | * @param in stanceId | |
| 709 | * @param st udyId | |
| 710 | * @param pa tientId | |
| 711 | * @return | |
| 712 | * / | |
| 713 | pu blic stati c String b uildDocume ntUniqueId (String in stanceId, String stu dyId, Stri ng patient Id) | |
| 714 | { | |
| 715 | retu rn | |
| 716 | instan ceId + | |
| 717 | URN.na mespaceSpe cificStrin gDelimiter + | |
| 718 | studyI d + | |
| 719 | URN.na mespaceSpe cificStrin gDelimiter + | |
| 720 | patien tId; | |
| 721 | } | |
| 722 | ||
| 723 | pu blic stati c String[] parseDocu mentUnique Id(String documentId ) | |
| 724 | th rows Globa lArtifactI dentifierF ormatExcep tion | |
| 725 | { | |
| 726 | Matc her matche r = ImageU RN.documen tUniqueIdP attern.mat cher(docum entId); | |
| 727 | if(! matcher.ma tches()) | |
| 728 | throw new Global ArtifactId entifierFo rmatExcept ion("'" + documentId + "' is n ot a valid document identifier for type 'ImageURN' ."); | |
| 729 | ||
| 730 | retu rn new Str ing[]{ | |
| 731 | matche r.group(DO CUMENTUNIQ UEID_DOCUM ENT_ID_GRO UP), | |
| 732 | matche r.group(DO CUMENTUNIQ UEID_GROUP _ID_GROUP) , | |
| 733 | matche r.group(DO CUMENTUNIQ UEID_PATIE NT_ID_GROU P)}; | |
| 734 | ||
| 735 | } | |
| 736 | ||
| 737 | @O verride | |
| 738 | pu blic int c ompareTo(G lobalArtif actIdentif ier o) | |
| 739 | { | |
| 740 | retu rn GlobalA rtifactIde ntifierImp l.compareT o(this, o) ; | |
| 741 | } | |
| 742 | ||
| 743 | @O verride | |
| 744 | pu blic Strin g getImagi ngIdentifi er() | |
| 745 | { | |
| 746 | retu rn getImag eId(); | |
| 747 | } | |
| 748 | ||
| 749 | @O verride | |
| 750 | pu blic Strin g getRepos itoryUniqu eId() | |
| 751 | { | |
| 752 | retu rn this.or iginatingS iteId; | |
| 753 | } | |
| 754 | ||
| 755 | @O verride | |
| 756 | pu blic Image URN clone( ) | |
| 757 | th rows Clone NotSupport edExceptio n | |
| 758 | { | |
| 759 | try | |
| 760 | { | |
| 761 | return create(ge tOriginati ngSiteId() , getImage Id(), getS tudyId(), getPatient Id(), getI mageModali ty()); | |
| 762 | } | |
| 763 | catc h (URNForm atExceptio n e) | |
| 764 | { | |
| 765 | throw new CloneN otSupporte dException (e.getMess age()); | |
| 766 | } | |
| 767 | } | |
| 768 | ||
| 769 | pu blic Study URN getPar entStudyUR N() | |
| 770 | th rows URNFo rmatExcept ion | |
| 771 | { | |
| 772 | Stud yURN study Urn = | |
| 773 | StudyURN Factory.cr eate(getOr iginatingS iteId(), g etStudyId( ), getPati entId(), S tudyURN.cl ass); | |
| 774 | stud yUrn.setPa tientIdent ifierTypeI fNecessary (getPatien tIdentifie rType()); | |
| 775 | retu rn studyUr n; | |
| 776 | } | |
| 777 | ||
| 778 | @O verride | |
| 779 | pr otected in t getPatie ntIdentifi erTypeAddi tionalIden tifierInde x() | |
| 780 | { | |
| 781 | retu rn ADDITIO NAL_IDENTI FIER_PATIE NT_IDENTIF IER_TYPE_I NDEX; | |
| 782 | } | |
| 783 | ||
| 784 | pu blic Image URN cloneW ithNewSite (String ne wOriginati ngSiteId) | |
| 785 | th rows Clone NotSupport edExceptio n | |
| 786 | { | |
| 787 | try | |
| 788 | { | |
| 789 | ImageU RN urn = c reate(newO riginating SiteId, ge tImageId() , getStudy Id(), getP atientId() , getImage Modality() ); | |
| 790 | urn.se tPatientId entifierTy peIfNecess ary(this.g etPatientI dentifierT ype()); | |
| 791 | return urn; | |
| 792 | } | |
| 793 | catc h (URNForm atExceptio n e) | |
| 794 | { | |
| 795 | throw new CloneN otSupporte dException (e.getMess age()); | |
| 796 | } | |
| 797 | } | |
| 798 | ||
| 799 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.