From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.140.235.204 with SMTP id g195mr48383555qhc.3.1435089067762; Tue, 23 Jun 2015 12:51:07 -0700 (PDT) X-Received: by 10.140.101.22 with SMTP id t22mr344751qge.32.1435089067729; Tue, 23 Jun 2015 12:51:07 -0700 (PDT) Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!q107no2924402qgd.0!news-out.google.com!4ni2558qgh.1!nntp.google.com!z60no2922610qgd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 23 Jun 2015 12:51:07 -0700 (PDT) In-Reply-To: <86y4jaqzdx.fsf@stephe-leake.org> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.99.95.58; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 83.99.95.58 References: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> <17436268-aceb-461f-bdcf-eee8436cd0e6@googlegroups.com> <86y4jaqzdx.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: What do you think about this? From: Laurent Injection-Date: Tue, 23 Jun 2015 19:51:07 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:193750 Date: 2015-06-23T12:51:07-07:00 List-Id: On Tuesday, 23 June 2015 16:21:17 UTC+2, Stephen Leake wrote: > I did not download and compile it, but I did browse around it a bit. That's why I like git. > The code looks clean and well-organized, Ok that is already a good thing to hear. >What is the whole thing supposed to do? It is supposed to generate something like this: mtrsl|pi12345678910|p2164|pp907088|p5907088|si|s040330|ssPLAIES|s5PLAIES|ci= 501502240387|c040330|ctAERO|ta|rtAST-N264|rr10335191|t12|o1esccol|ra|a1tem|= a3<=3D4|a4S|ra|a1am|a34|a4S|ra|a1amc|a34|a4S|ra|a1tzp|a3<=3D4|a4S|ra|a1rox|= a34|a4S|ra|a1tax|a3<=3D1|a4S|ra|a1taz|a3<=3D1|a4S|ra|a1fep|a3<=3D1|a4S|ra|a= 1etp|a3<=3D0,5|a4S|ra|a1mem|a3<=3D0,25|a4S|ra|a1an|a3<=3D2|a4S|ra|a1gm|a3<= =3D1|a4S|ra|a1cip|a3<=3D0,25|a4S|ra|a1lev|a3<=3D0,12|a4S|ra|a1tgc|a3<=3D0,5= |a4S|ra|a1fos|a3<=3D16|a4S|ra|a1ftn|a3<=3D16|a4S|ra|a1sxt|a3<=3D20|a4S|zz| And then write it in a text file.=20 The hospital I work for has acquired a new software for epidemical surveill= ance. I work in the lab in the microbiology department and I have been aske= d to verify the transmission of the results from the analyzer to the softwa= re used by the nurses/docters.=20 I have 3 possibilities to do that: 1) launch tests but that takes 24hrs and I have no influence on the result 2) use existing tests and rename them. Which means I have to tinker around = with results of actual patients. Is bad because of the iso certification wh= ich requires everything to be traceable. No influence on the result 3) write a program which generates textfiles with random results which I ca= n copy into the transfer folder on the analyzer.=20 > What is a "antibiogramme"? The analyzer is testing the susceptibility of a bacteria against a number o= f antibiotics. The whole result is called an antibiogramme.=20 The CMI (MIC in english) is the "minimum inhibitory concentration" that is = the lowest concentration of the antibiotic required to kill 99.9% of the ba= cteria.=20 There are breakpoints for every antibiotic which define if it is S =3D sens= ible, I =3D intermediate (could work) or R =3D resistant. That is called th= e susceptibility. > What is a "dossier"? medical file in this case. I am used to the french names of the whole stuff= so I used them everywhere. >but it lacks comments Yup something I have to improve. In this case the program is only used by m= e and quite probable only once. As well as a todo list so that I remember w= here I left in the case I don't work on a project for longer time. > There are cases where a function returns a V_String but could return a > plain String; in general, unless the result _must_ be a V_String for > some reason, it is better to return a String; then the caller can just > use it without conversion, or declare a local variable to hold it. I have quite often problems with different string types and their behavior.= So I followed Bruce B's recommendation (some earlier post: "Annoying behavior") to make a package: with Ada.Strings.Bounded; with Ada.Strings.Fixed; package Common_Defs_BCI is V_String_Length : constant :=3D 64; package V_String is new Ada.Strings.Bounded.Generic_Bounded_Length (V_String_Length); function "+" (Right : V_String.Bounded_String) return String renames V_String.To_String; function "+" (Right : String) return V_String.Bounded_String is (V_String.To_Bounded_String (Right)); function Trim (Right : String) return V_String.Bounded_String is (V_String.To_Bounded_String (Ada.Strings.Fixed.Trim (Right, Ada.String= s.Both))); end Common_Defs_BCI; So no more confusion with different string types.=20 >... it is better to return a String; then the caller can just use it witho= ut conversion, or declare a >local variable to hold it. Well without the "+" conversion function I would agree because the To_Bound= ... thing is annoying. For the last part I don't understand what you mean. In the main file I have= the function Make_File_Name where File_Name is local variable. If it is of= type String or the custom V_String, where is the difference? Ok I have to = convert it later in procedure Generate. Requires an additional "+". I find = it is a quite good tradeoff for the flexibility it offers me.=20 If you have an example where you think that it is not recommended I'd like = to see. I have of course no idea how expensive that is in terms of computat= ion power. function Make_File_Name (How_Many : in Positive) return V_String.Bounded= _String is File_Name : V_String.Bounded_String; Right_Now : Ada.Calendar.Time :=3D Ada.Calendar.Clock;... begin ... File_Name :=3D +("VITEK2-BCI_" &...; return File_Name; end Make_File_Name; procedure Generate (How_Many : in Positive) is File : Ada.Text_IO.File_Type; begin -- Generate for Counter in 1 .. How_Many loop declare -- removed the declaration of the different objects begin -- declare Ada.Text_IO.Create (File =3D> File, Mode =3D> Ada.Text_IO.Out_File, Name =3D> +Make_File_Name (Counter)); <--- BCI_Messages.IO.To_BCI (Item =3D> Test_Message, File =3D> File)= ; Ada.Text_IO.Close (File); end; -- declare end loop; end Generate; For the CMI I would have preferred to use enumerations but that doesn't see= m to be possible: CMI_Type is ("<=3D1","0,004","3"); or CMI_Type is ("1","2","3");=20 but that works CMI_Type is ('1','2','3'); ? For the SIR I have used an enumeration at the beginning but I had some prob= lems getting the result written to the text file. So the V_String solved mo= st of the problems. I have to wait for the person which takes care of the informatics in the la= b before I inject the text files into the analyzer. Would be stupid to blow= up the online connections with an ill formatted result and no one there to= restore them. Thanks Stephen for your time and comments. Laurent