예제 #1
0
        public async Task <ActionResult> Get(string fhirserver, string metadata_endpoint,
                                             string interaction_list, string resource_list)
        {
            string metadataEndpoint = "metadata?_format=json";

            string[] interactionList = { "all" };
            string[] resourceList    = { "all" };

            if (!String.IsNullOrEmpty(metadata_endpoint))
            {
                metadataEndpoint = metadata_endpoint;
            }

            if (!String.IsNullOrEmpty(interaction_list))
            {
                interactionList = interaction_list.Split(",");
            }

            if (!String.IsNullOrEmpty(resource_list))
            {
                resourceList = resource_list.Split(",");
            }

            string arm = await Fhir2Apim.GetArmApiFromMetadata(fhirserver, metadataEndpoint, interactionList, resourceList);

            return(new ContentResult()
            {
                Content = arm,
                StatusCode = 200,
                ContentType = "application/json"
            });
        }
예제 #2
0
        public async Task ArmApiGeneration(string fhirServerUrl, string description)
        {
            string [] interactionList  = { "all " };
            string [] resourceList     = { "all " };
            string    metadataEndpoint = "metadata?_format=json";

            string armApiString = await Fhir2Apim.GetArmApiFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList);

            JObject armApi = JObject.Parse(armApiString);

            Assert.Equal(description, (string)armApi["resources"][0]["properties"]["description"]);
        }
예제 #3
0
        public static async Task Main(string[] args)
        {
            string fhirServerUrl    = null;
            string metadataEndpoint = "metadata?_format=json";
            string outFileName      = "out.json";
            string format           = "swagger";

            string[] interactionList = { "all" };
            string[] resourceList    = { "all" };

            int arg = 0;

            while (arg < args.Length)
            {
                if (args[arg] == "-s" || args[arg] == "--server")
                {
                    arg++;
                    fhirServerUrl = args[arg++];
                }
                else if (args[arg] == "-m" || args[arg] == "--meta")
                {
                    arg++;
                    metadataEndpoint = args[arg++];
                }
                else if (args[arg] == "-o" || args[arg] == "--out")
                {
                    arg++;
                    outFileName = args[arg++];
                }
                else if (args[arg] == "-r" || args[arg] == "--resources")
                {
                    arg++;
                    resourceList = args[arg++].Split(",");
                }
                else if (args[arg] == "-i" || args[arg] == "--interactions")
                {
                    arg++;
                    interactionList = args[arg++].Split(",");
                }
                else if (args[arg] == "-f" || args[arg] == "--format")
                {
                    arg++;
                    if (args[arg] != "swagger" && args[arg] != "arm")
                    {
                        Console.WriteLine("Valid formats are 'swagger' or 'arm'");
                        PrintUsage();
                        return;
                    }
                    format = args[arg++];
                }
                else
                {
                    Console.WriteLine($"Unknow command line argument: {args[arg]}");
                    PrintUsage();
                    return;
                }
            }


            if (String.IsNullOrEmpty(fhirServerUrl))
            {
                Console.WriteLine("No FHIR server URL provided");
                PrintUsage();
                return;
            }

            string output = null;

            if (format == "swagger")
            {
                output = await Fhir2Apim.GetSwaggerFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList);
            }
            else
            {
                output = await Fhir2Apim.GetArmApiFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList);
            }

            System.IO.File.WriteAllText($"{outFileName}", output);
        }