problem build fhir with german basis profil - hl7-fhir

i use vb.net with visualStudio. i have installed the nuget Hl7.Fhir Version3.6.0 and other Hl7.Fhir-nugets (serializer a.s.o V3.6.0)
i have a Problem to build a fhir with resource organization(for example, same with patient) with
german basis profil (https://simplifier.net/ditconnectathon/kbvprforpatient).
I init extension with URL and value, i have the organization and the address and the line. i can add enumerables to line, but no extension.
i am a newbie... All other resources i can build und serialize. My Question: is this a porblem with me and you can show me a solution, or is this (worst case) a problem with Fhir rh4 and the german basis profil. What is then the solution....?
here some primitive code :
dim organization as new organzation
dim adr as new address
dim ext as new extension 'i have a function to make extension returns
ext=FunctionBuildExtension(url,value)
adr.line=new string() {city,street}
' here should placed the addExtension, but i dont know how...
' adr.line.???
organzation.address.add(adr)
this i want to have:
fhir.organization.xml
thank you for your help

The Address.Line is of the native .Net string type, which indeed does not know anything about extensions. You should also have an Address.LineElement which can take an extension.
Here's an example in C# of adding an extension to a primitive typed element: https://docs.fire.ly/projects/Firely-NET-SDK/model/extensions.html

Related

codename one "cn1-data-access-lib" utf-8 source

I wok on my first CN1 app.
I have to use sqlite database acces. I used the cn1-data-access-lib import from json file feature.
It works, but the file what I import is UTF-8 encoded and Includes accented characters. The Hungarian language is just that πŸ™‚ .
After import the accented characters became unrecognizable in emulator.
Made an app on buidserver, the app worked fine on an android phone. The phone setted to Hungarian.
I checked the source code. The importer class has the β€œpublic final void importJSON(InputStream is, String selector)” method which instantiate an InputStreamReader without the second (charset or charsetName) parameter. This procedure can not be overridden.
Is there a solution proposal?
If I could get a free hand, I would be able to use custom inporter class. This is a solution to the problems not yet known.
Best regards,
Peter
It looks like a bug in DAO cn1lib: https://github.com/shannah/cn1-data-access-lib/blob/master/src/ca/weblite/codename1/db/Importer.java#L254
It uses this code:
Map data = parser.parseJSON(new InputStreamReader(is));
It should at least default to UTF8. I created a pull request for this: https://github.com/shannah/cn1-data-access-lib/pull/10
Steve should address it there.

When is "Set" required in lotus script when setting an environment variable

I've inherited a nightmare of a project from the days when I can only assume LOC was an acceptable KPI in lotus script. I'm working on refactoring repetitive code after I've been asked to make a change to how our company's apps work. The code below illustrates something I don't understand about the syntax of Lotus Script -- I'm getting an error in the domino designer that on the "Control = UIDoc.Document....." line that A "Set" is required. Looking at existing code, sometimes Set is used for assignment, sometimes it is not. I'm trying to read the lotus script doc's, but haven't yet found an explanation of the difference. Any change someone could illuminate me on when Set should be used and when it should not? If it helps I have a strong C# background with some minor experience in interpreted languages like JS and PHP
Class DeploymentType
Private ProductName As String
Private ControlSuffix As String
Private TypeHeader As String
Private Control As NotesRichTextItem
Sub new (Product As String, Suffix As String, Header As String, UIDoc As NotesUIDocument)
'These three assignments do not show an error without set
ProductName = Product
ControlSuffix = Suffix
TypeHeader = Header
'This assignment shows an error unless I prepend it with "Set"
Set Control = UIDoc.Document.GetFirstItem(ProductName + ControlSuffix)
End Sub
The set keyword has nothing to do with environment variables. The UIDoc.Document method returns an object in the NotesDocument class. Set is required for assigning object references. Assignments to scalar variables with simple built-in data types (string, integer, boolean, byte, etc.) do not require Set.
Use Set for objects from the Notes product classes, any OLE or COM classes or any classes that you define in LotusScript itself.

FHIR.net Property added to Practitioner

We're currently using FHIR.net library(STU3). The FHIR Server from which we are receiving information has added a practitionerRole property to the Practitioner. Thus when Reading a Practitioner, we get the following Exception:
Encountered unknown member 'practitionerRole' while de-serializing (at path 'line 1, pos 2') in Hl7.Fhir.Rest.HttpToEntryExtensions.parseResource(String bodyText, String contentType, ParserSettings settings, Boolean throwOnFormatException)
The only solution I could think of is to add a practitionerRole property in the Model\Generated\Practitioner.cs class that would go like that:
[FhirElement("practitionerRole", InSummary = true, Order = 115)]
[Cardinality(Min = 0, Max = -1)]
[DataMember]
public List<Hl7.Fhir.Model.PractitionerRole> PractitionerRole
{
get { if (_PractitionerRole == null) _PractitionerRole = new List<Hl7.Fhir.Model.PractitionerRole>(); return _PractitionerRole; }
set { _PractitionerRole = value; OnPropertyChanged("PractitionerRole"); }
}
private List<Hl7.Fhir.Model.PractitionerRole> _PractitionerRole;
Is there any other solution than that? If so, which one?
Thank you in advance
It sounds like you're talking to a DSTU2 server. You'll need some sort of a conversion layer between your system and theirs.
As stated by FHIR employees in https://sea-region.github.com/standardhealth/shr_spec/issues/187 , DSTU2 and STU3 are two different versions of FHIR standard. If you check their last commits (https://www.nuget.org/packages?q=Fhir) as in August 2019, you will see they are maintaining both standards. That is probably due to the hospitals using STU3 version and do not want to adapt to the new version of FHIR, which is DSTU2.
The problem arises when you want to reach a class, let's say Patient, that coexists in two versions. Compiler can not decide which "Patient" class you refer to.
Normally, you could specialize using imports or predescription such as :
Hl7.Fhir.Model.Patient p = new Hl7.Fhir.Model.Patient();
BUT, Patient classes in both versions are described as Hl7.Fhir.Model.Patient. Their namespace is "Hl7.Fhir.Model" and their class name is "Patient".
Normally, you could workaround using keyword:
extern alias
BUT, since model classes in FHIR are read only, you can not use both versions in same project.
You need to uninstall unwanted FHIR version and install wanted version. To do these in Visual Studio,
go to Solution Manager> right click on "Manage Nuget Packages" > Search "Fhir" > uninstall unwanted FHIR version > install wanted version
You can also follow the unanswered question below:
C# T4 Template equivalent for "extern alias"

Add item to Error List in Macro

I want to notify the user of the macro if something went wrong during the execution of the macro. I was wondering if it would be possible to add an item to the Visual Studio error list?
It is possible to do so from within an AddIn (like here), but I would like to do the same thing from a macro.
Edit
To further clarify what i want to achive, here is the sample from the Samples macro library (Alt+F8 -> Samples -> Utilities -> SaveView())
Sub SaveView()
Dim name As String
name = InputBox("Enter the name you want to save as:", "Save window layout")
If (name = "") Then
MsgBox("Empty string, enter a valid name.")
Else
DTE.WindowConfigurations.Add(name)
End If
End Sub
Instead of the MsgBox("...") alert I want to put the error into the VS error list.
You can add an item in the Task List easily from your macro. Just use the AddTaskToList method from that article and change m_objDTE to DTE. I've tried it and it worked.
However, adding the item in Error List, is probably impossible. You need to call VS services, see how adding an error is done in an add-in. I created a macro from this code and it didn't work. In general, VS services don't work in macros. I was able to create ErrorListProvider successfully. I could access it's methods and properties. But calling ErrorListProvider.Task.Add caused COM exception. If you want to play with it, several notes:
As described in the article, you need to get 4 assemblies out of the GAC e.g. to c:\dlls\ directory. Since Macros IDE doesn't allow you to browse when you Add Reference, you need to copy these dlls into ...\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies directory (change the 10.0 to your VS version). Then, when you Add Reference in Macros IDE, you should see the assemblies.
The GetService function always returned Nothing. Add the following field to the class:
Private serviceProvider As IServiceProvider = New Microsoft.VisualStudio.Shell.ServiceProvider(CType(DTE, Microsoft.VisualStudio.OLE.Interop.IServiceProvider))
and in GetService function change line:
objService = Microsoft.VisualStudio.Shell.Package.GetGlobalService(serviceType)
to
objService = serviceProvider.GetService(serviceType)
As I wrote, everything seems OK then but ErrorListProvider.Task.Add fails.
I think that for your situation outputting something to your own output pane would be more suitable. The error list is generally used for errors within the project the user is working on, not for errors caused by running macros. Especially when someone says it can't be done. :)
Outputting to your own output pane is pretty easy:
DTE.Windows.Item(Constants.vsWindowKindOutput).Activate()
Dim panes As OutputWindowPanes = window.OutputWindowPanes
Dim my_pane As OutputWindowPane
Try
my_pane = panes.Item("SaveView")
Catch exception As System.ArgumentException
my_pane = panes.Add("SaveView")
End Try
my_pane.Activate()
my_pane.OutputString("Empty string, enter a valid name." + vbCrLf)
Hope this helps.
Cheers,
Sebastiaan
Is this not what you want?
HOWTO: Add an error with navigation to the Error List from a Visual Studio add-in
http://www.mztools.com/articles/2008/MZ2008022.aspx

Copy object values in Visual Studio debug mode

In Visual Studio debug mode it's possible to hover over variables to show their value and then right-click to "Copy", "Copy Expression" or "Copy Value".
In case the variable is an object and not just a basic type, there's a + sign to expand and explore the object. It there a way to copy all that into the clipboard?
In the immediate window, type
?name_of_variable
This will print out everything, and you can manually copy that anywhere you want, or use the immediate window's logging features to automatically write it to a file.
UPDATE: I assume you were asking how to copy/paste the nested structure of the values so that you could either search it textually, or so that you can save it on the side and then later compare the object's state to it. If I'm right, you might want to check out the commercial extension to Visual Studio that I created, called OzCode, which lets you do these thing much more easily through the "Search" and "Compare" features.
UPDATE 2 To answer #ppumkin's question, our new EAP has a new Export feature allows users to Export the variable values to Json, XML, Excel, or C# code.
Full disclosure: I'm the co-creator of the tool I described here.
You can run below code in immediate window and it will export to an xml file the serialized XML representation of an object:
(new System.Xml.Serialization.XmlSerializer(obj.GetType())).Serialize(new System.IO.StreamWriter(#"c:\temp\text.xml"), obj)
Source: Visual Studio how to serialize object from debugger
Most popular answer from https://stackoverflow.com/a/23362097/2680660:
With any luck you have Json.Net in you appdomain already. In which
case pop this into your Immediate window:
Newtonsoft.Json.JsonConvert.SerializeObject(someVariable)
Edit: With .NET Core 3.0, the following works too:
System.Text.Json.JsonSerializer.Serialize(someVariable)
There is a extension called Object Exporter that does this conveniently.
http://www.omarelabd.net/exporting-objects-from-the-visual-studio-debugger/
Extension: https://visualstudiogallery.msdn.microsoft.com/c6a21c68-f815-4895-999f-cd0885d8774f
You can add a watch for that object, and in the watch window, expand and select everything you want to copy and then copy it.
By using attributes to decorate your classes and methods you can have a specific value from your object display during debugging with the DebuggerDisplay attribute e.g.
[DebuggerDisplay("Person - {Name} is {Age} years old")]
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
I always use:
string myJsonString = JsonConvert.SerializeObject(<some object>);
Then I copy the string value which unfortunately also copies the back slashes.
To remove the backlashes go here:
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_replace
Then within the <p id="demo">Visit Microsoft!</p> element replace the text with the text you copied.
then replace the var res = str.replace("Microsoft", "W3Schools"); line with
var res = str.replace(/\\/g, '')
Run these new changes but don't forget to click the "try it" button on the right.
Now you should have all the text of the object in json format that you can drop in a json formatter like http://jsonformatter.org or to create a POCO you can now use http://json2csharp.com/
ObjectDumper.NET
This is an awesome way!
You probably need this data for a unit test, so create a Sandbox.cs temporary test or you can create a Console App.
Make sure to get NuGet package, ObjectDumper.NET, not ObjectDumper.
Run this test (or console app)
View test output or text file to get the C# initializer code!
Code:
[TestClass]
public class Sandbox
{
[TestMethod]
public void GetInitializerCode()
{
var db = TestServices.GetDbContext();
var list = db.MyObjects.ToList();
var literal = ObjectDumper.Dump(list, new DumpOptions
{
DumpStyle = DumpStyle.CSharp,
IndentSize = 4
});
Console.WriteLine(literal); // Some test runners will truncate this, so use the file in that case.
File.WriteAllText(#"C:\temp\dump.txt", literal);
}
}
I used to use Object Exporter, but it is 5 years old and no longer supported in Visual Studio. It seems like Visual Studio Extensions come and go, but let's hope this NuGet package is here to stay! (Also it is actively maintained as of this writing.)
Google led me to this 8-year-old question and I ended up using ObjectDumper to achieve something very similar to copy-pasting debugger data. It was a breeze.
I know the question asked specifically about information from the debugger, but ObjectDumper gives information that is basically the same. I'm assuming those who google this question are like me and just need the data for debugging purposes and don't care whether it technically comes from the debugger or not.
I know I'm a bit late to the party, but I wrote a JSON implementation for serializing an object, if you prefer to have JSON output. Uses Newtonsoft.Json reference.
private static void WriteDebugJSON (dynamic obj, string filePath)
{
using (StreamWriter d = new StreamWriter(filePath))
{
d.Write(JsonConvert.SerializeObject(obj));
}
}
I've just right clicked on the variable and selected AddWatch, that's bring up watch window that consists of all the values. I selected all and paste it in a text a text editor, that's all.
Object Dumper is a free and open source extension for Visual Studio and Visual Studio Code.
"Dump as" commands are available via context menu in the Code and Immediate windows.
It's exporting objects to:
C# object initialization code,
JSON,
Visual Basic object initialization code,
XML,
YAML.
I believe that combined with the Diff tool it can be helpful.
I'm the author of this tool.
if you have a list and you want to find a specific variable:
In the immediate window, type
myList.Any(s => s.ID == 5062);
if this returns true
var myDebugVar = myList.FirstOrDefault(s => s.ID == 5062);
?myDebugVar
useful tips here, I'll add my preference for when i next end up here asking this question again in the future.
if you don't mind adding an extension that doesn't require output files or such there's the Hex Visualizer extension for visual studio, by mladen mihajlovic, he's done versions since 2015.
provides a nice display of the array via the usual magnifine glass view object from the local variables window.
https://marketplace.visualstudio.com/items?itemName=Mika76.HexVisualizer2019 is the 2019 version.
If you're in debug mode, you can copy any variable by writing copy() in the debug terminal.
This works with nested objects and also removes truncation and copies the complete value.
Tip: you can right click a variable, and click Copy as Expression and then paste that in the copy-function.
System.IO.File.WriteAllText("b.json", page.DebugInfo().ToJson())
Works great to avoid to deal with string debug format " for quote.
As #OmerRaviv says, you can go to Debug β†’ Windows β†’ Immediate where you can type:
myVariable
(as #bombek pointed out in the comments you don't need the question mark) although as some have found this limits to 100 lines.
I found a better way was to right click the variable β†’ Add Watch, then press the + for anything I wanted to expand, then used #GeneWhitaker's solution, which is Ctrl+A, then copy Ctrl+C and paste into a text editor Ctrl+V.

Resources