go to post Julius Kavay · Aug 21, 2021 First, resetting a password means, the user gets a new password, in your use case, this is not an option. Second, if you want (for whatever reason) to validate the user in some stage of the application, then you must calculate the PBKDF2 from useres input (the password) and from (the stored) salt. The hash you get should be equal to the hash, storted in the database. PBKDF2 is a one way salted password hash. By the way, you have to care about not to transfer the users (clear text) input to your computation over an unsecure way!
go to post Julius Kavay · Aug 18, 2021 I think, the $zconvert() function will cover only the necessary entities. But you can use a simple method to convert characters to currently known(*) entities. ClassMethod ToHTML(str) { for i=$length(str):-1:1 set c=$ascii(str,i) set:$data(^entityChars(0,c),c) $extract(str,i)=c quit str } ClassMethod FromHTML(str) { set i=0 while $locate(str,"&[A-Za-z]+;",i,j,v) { set:$data(^entityChars(1,v),c) s=$length(v), $extract(str,j-s,j-1)=$c(c), j=j-s+1 set i=j } quit str } I have a table (the ^entityChars() global) which contains more the 1400 entities. You can download the above class, together with the table from my FTP server (File: DC.Entity.xml): Adr: ftp.kavay.at Usr: dcmember Psw: member-of-DC A sample output: USER>write ##class(DC.Entity).ToHTML("Flávio Lúcio Naves Júnior") Flávio Lúcio Naves Júnior USER>write ##class(DC.Entity).FromHTML("Flávio Lúcio Naves Júnior") Flávio Lúcio Naves Júnior (*) Currently known, because (1) I do not have all the currently known entities in my table and (2) with each new day, the W3C and the Unicode consortium can extend the current entity list.
go to post Julius Kavay · Aug 18, 2021 www.intersystems.com --> Support&Learning --> WRC Direct --> Actions --> Online Distributions
go to post Julius Kavay · Aug 8, 2021 See this post https://community.intersystems.com/post/temporary-online-documentation-s...
go to post Julius Kavay · Aug 7, 2021 sorry, a doubleclick by mistake... May be the underlying software could prevent such stupid things in the future...
go to post Julius Kavay · Aug 5, 2021 First of all, if you want to transform a hex string into base64 (or whatever), then first you have to say, WHAT IS that hex string? According to your example set hexString = "4C5803040101020179C3913EC3BA7C4C580708010101021824584D4C" the string has 56 hex chars, so if you decode those 56 hex chars, the resulting string could be:a) 28 eigth bit characters orb) 14 sixteen bit chars or evenc) 7 characters, each 32 bits wide. For cases b) and c) you also have to define the endianness (big- or little-endian). Second, I assume, your hex-string represents 8-bit chars, so we get 28 characters after converting the hex-chars into a string. Converting to base64 means, you get for every 3 (8bit) chars four printable (8bit) chars. We add two padding chars to the 28 byte string, so we have 30 chars, now which are divisible by 3. This gives you 40 base64 encoded characters. But your Base64 encoding has 44 characters, which must be wrong. Here is a simple and working solution: Class DC.Util Extends %RegisteredObject { /// Hex to Base64 ClassMethod HexToB64(hex) { if $length(hex)#2 zt "ELEN" // trap, two hex chars should make up each byte set str="" for i=1:2:$length(hex) set str=str_$char($zhex($extract(hex,i,i+1))) quit $system.Encryption.Base64Encode(str,1) } /// Base64 to Hex ClassMethod B64ToHex(b64) { set str=$system.Encryption.Base64Decode(b64), hex="" for i=1:1:$length(str) set hex=hex_$extract($zhex($ascii(str,i)+256),2,3) quit hex } } and a short test set hexString = "4C5803040101020179C3913EC3BA7C4C580708010101021824584D4C" set b64String=##class(DC.Util).HexToB64(hexString) write b64String, !, ##class(DC.Util).B64ToHex(b64String), !,hexString TFgDBAEBAgF5w5E+w7p8TFgHCAEBAQIYJFhNTA== 4C5803040101020179C3913EC3BA7C4C580708010101021824584D4C 4C5803040101020179C3913EC3BA7C4C580708010101021824584D4C
go to post Julius Kavay · Aug 5, 2021 For such a task, the Horner's method was introduced. Fast and simple. ClassMethod BinToDec(bin) { if $translate(bin,10)="" { // formal check, bin should only contain '1' and '0' set res=0 for i=1:1:$length(bin) set res=res*2+$extract(bin,i) quit res } else { ztrap "NBIN" } } Hardcore ObjectScript programer place those few commands into one line bin2dec(bin) { s res=0 f i=1:1:$l(bin) { s res=res*2+$e(bin,i) } q res } and doesn't care about errors ;-))
go to post Julius Kavay · Aug 4, 2021 You can change the definition, the data remains as is. But you have to take care about your applications, like SQL-queries. For example a DATEPART() function could refuse to work because a property, defined as %String, may contain everything.
go to post Julius Kavay · Jul 20, 2021 Just a hint, I would take $ZD($h,2). For today, my development system (and systems at customers site) shows: Write $horolog - $zdate($horolog, 4) + 1 --> 65925.93 Write $zdate($horolog,4) --> 20.07.2021 Write $horolog - $zdate($horolog, 2) + 1 --> 65926 // expected value Later, this value (65925.93), as a $zdate() argument, gives you an <ILLEGAL VALUE> For $zdate($horolog,4), the link you provided says: 4 DD/MM/[YY]YY (01/07/97 or 27/03/2002) — European numeric format. You must specify the correct dateseparator character (/ or .) for the current locale.
go to post Julius Kavay · Jul 15, 2021 Obviously, the response.Data does not contain valid JSON. You can simply check the received data by putting the data aside in a temporary global, something like this: do request.HttpResponse.Data.Rewind() set ^temp.debug($j,"size")=request.HttpResponse.Data.Size set ^("data")=request.HttpResponse.Data.Read(request.HttpResponse.Data.Size) // or just the first 1000 bytes zw ^temp.debug Now you can take a look on the incoming data, maybe there is an encoding problem or the data do not adhere to JSON specification
go to post Julius Kavay · Jul 13, 2021 According to your code, the variable obx5 contains the base64 encoded tiff image. There is one thing I do not understand: what are those "\.br\" char-sequences, how they came into the base64 stream? Anyway, I suppose they are OK (those "\.br\"s), so put all those pieces together and decode all at once: set input = "" for i=1:1:$L(obx5,"\.br\") { set input = input _ $P(obx5,"\.br\",i)) } Do obj.Write($system.Encryption.Base64Decode(input)) Now you should have a correct decoded image, provided, the obx5 variable really contains the original base64 encoded tiff image with randomly inserted "\.br\" chars (for whatever reason).
go to post Julius Kavay · Jun 21, 2021 I have no idea, what is the date format of PID 7.1, but I'm sure, you can convert this date to $h format, so the answer to your question is set age = $h - $zdh(PID7.1Date,?) \ 365.25 now <age> contains the patients age in full years
go to post Julius Kavay · Jun 8, 2021 Somehow I don't get you right. To save obj.%Size() in a variable, just do a simple assign set myVariable = obj.%Size() but I'm pretty shure, this was not your intended question. I suppose, you have JSON formatted data (a string or a stream) and you want to store those data in a table. Am I right? If yes, then follow the next steps: 1) create a class which describes your JSON objects (strings) Class DC.SehindeRaji Extends (%Persistent, %JSON.Adaptor) { Property byr As %String(%JSONFIELDNAME = "byr:"); Property iyr As %String(%JSONFIELDNAME = "iyr:"); Property eyr As %String(%JSONFIELDNAME = "eyr:"); // do the same for all other fields ClassMethod Import(data) { set obj=..%New() // create a new DC.SehindeRaji object set sts=obj.%JSONImport(data,"") // import the (JSON) data if sts { set sts = obj.%Save() if sts { write "Saved, ID=",obj.%Id(),! quit 1 } else { write "Not saved, Err=",$system.Status.GetOneErrorText(sts),! quit 0 } } else { write "Can't import: ",$system.Status.GetOneErrorText(sts),! quit 0 } } } 2) You can create some test data (interactively) in a terminal session set dynObj = {"byr:":"1937", "iyr:":"2017", "eyr:":"2020"} set data = dynObj.%ToJSON() or get your data somehow from an input (possibly from a file), the only important thing is, your data should look like this write data --> {"byr:":"1937","iyr:":"2017","eyr:":"2020"} 3) import those data write ##class(DC.SehindeRaji).Import(data) --> Saved, ID=1 4) Now open the saved data and check the result set oref = ##class(DC.SehindeRaji).%OpenId(1) write oref.byr --> 1937 write oref.iyr --> 2017 write oref.%JSONExportToString(.exported,"") --> 1 write exported --> {"byr:":"1937","iyr:":"2017","eyr:":"2020"} zw ^DC.SehindeRajiD ^DC.SehindeRajiD=1 ^DC.SehindeRajiD(1)=$lb("","1937","2017","2020") I hope, this is what yoy want to do...
go to post Julius Kavay · Jun 8, 2021 The facts:1) According to the error message: "The system cannot find the file specified."2) Futhermore, the error message shows slashes and backslashes, mixing is rarely good, Windows uses "\", Unix "/" What to do is:1) check the filename, you want to send (including the path)2) check the existence of the file3) Under which user accont is IRIS/Cache running?4) May this user read the file?
go to post Julius Kavay · Jun 2, 2021 If you can call a JavaScript function, then you could do something like this... <html> <head><title>Test</title> <link id="fav" rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAF0lEQVQokWP8z0AaYCJR/aiGUQ1DSAMAQC4BH5CRCM8AAAAASUVORK5CYII="> <script> function changeFavicon() { var lid=document.getElementById("fav"); if (lid) { lid.setAttribute("href","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAGElEQVQokWNk+M9AEmAiTfmohlENQ0kDAD8vAR+xLJsiAAAAAElFTkSuQmCC"); } } </script> </head> <body> <button onclick="changeFavicon();")>Change my favicon</button><br> </body> </html> The (red and green) icons are just a demo example.
go to post Julius Kavay · May 26, 2021 Yes, use the TRACE utility. See also https://community.intersystems.com/post/macro-know-all-parameters-transf...
go to post Julius Kavay · May 25, 2021 If I got you correctly... for IRIS (and newer Cache Versions) you can use select * from INFORMATION_SCHEMA.ROUTINES where ROUTINE_NAME='...' and for older Cache versions try select * from %Dictionary.CompiledMethod where SqlProc=1 and Name='...' (but be patient, this takes some time)
go to post Julius Kavay · May 21, 2021 You have a string of digits... like set result="12345678900987654321" then you can easily extract groups of four digits as for i=1:4:$length(result) write $extract(result,i,i+3),! this gives you 1234 5678 9009 8765 4321 assuming, there are no other characters between those numbers...
go to post Julius Kavay · May 14, 2021 Long time ago I did some connections to external databases (MySql and PostGres).The essential parts such a connection are: 1) First, you have to create in your OS the corresponding ODBC Data Source entries (System-DSN) after installing the required DB-Driver 2) The connection set gtwConn=##class(%SQLGatewayConnection).%New(), gtwHandle=0 if gtwConn.Connect(OdbcName, OdbcUser, OdbcPass) { if gtwConn.AllocateStatement(.gtwHandle) { // check gtwConn.GatewayStatus // etc. } else { write "Can't Allocate: "_OdbcName } } else { write "Can't connect to "_OdbcName } 3) SQL-Commands do gtwConn.CloseCursor(gtwHandle) if gtwConn.PrepareW(gtwHandle, sqlStatement) { if gtwConn.Execute(gtwHandle) { ... ... } else { /* check gtwConn.GatewayStatus */ } } else { /* check.gtwConn.GatewayStatus */ } 4) Finish if gtwConn { do gtwConn.DropStatement(gtwHandle), gtwConn.Disconnect() set gtwConn="", gtwHandle="" }