<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ajay on Medium]]></title>
        <description><![CDATA[Stories by Ajay on Medium]]></description>
        <link>https://medium.com/@ajnabha6688?source=rss-a54e18a467d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*i6cElsEVauUNJ0YkQcGZbA.jpeg</url>
            <title>Stories by Ajay on Medium</title>
            <link>https://medium.com/@ajnabha6688?source=rss-a54e18a467d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:19:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajnabha6688/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Common FHIR Java Library — Dynamically Convert Java Objects to FHIR Resources]]></title>
            <link>https://medium.com/@ajnabha6688/common-fhir-java-library-dynamically-convert-java-objects-to-fhir-resources-69ca85db0e98?source=rss-a54e18a467d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/69ca85db0e98</guid>
            <dc:creator><![CDATA[Ajay]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 11:36:01 GMT</pubDate>
            <atom:updated>2025-02-20T11:43:24.981Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Common FHIR Java Library — Dynamically Convert Java Objects to FHIR Resources</strong></h3><p><strong>Introduction</strong> In the rapidly evolving landscape of healthcare interoperability, Fast Healthcare Interoperability Resources (FHIR) has emerged as a standard for exchanging healthcare information. However, integrating FHIR into Java applications can be a challenge due to the complex structure of FHIR resources. To simplify this, we have developed the <strong>Common FHIR Java Library</strong>, an open-source tool that allows developers to dynamically convert Java objects into FHIR resources using a configurable JSON mapping.<br>Youngsoft India, the owner of this open-source project, has developed the Common FHIR Java Library to facilitate seamless conversion of Java objects into FHIR (Fast Healthcare Interoperability Resources) format. This library allows dynamic conversion using a configurable JSON mapping, enabling developers to integrate their own Java objects into FHIR resources effortlessly.</p><p>This blog will guide you through the library’s features, setup, and how to use it effectively in your projects.</p><h3>What is the Common FHIR Java Library?</h3><p>The <strong>Common FHIR Java Library</strong> is designed to help Java developers easily transform their domain-specific objects into FHIR-compliant JSON structures. By defining a mapping configuration in a JSON file, developers can control how Java object fields are converted into FHIR attributes without modifying their source code.</p><h4>Key Features:</h4><ul><li><strong>Dynamic Object Conversion:</strong> Convert Java objects to FHIR resources using a flexible JSON configuration.</li><li><strong>Easy Integration:</strong> Packaged as a JAR file for seamless integration into Java projects.</li><li><strong>Custom Field Mappings:</strong> Define mappings between Java fields and FHIR attributes.</li><li><strong>Support for Nested Fields:</strong> Recursively map nested Java fields to structured FHIR resources.</li><li><strong>Extensibility:</strong> Supports custom field converters for complex mapping needs.</li></ul><h3>Prerequisites</h3><p>Before using the library, ensure you have:</p><ul><li><strong>Java 8 or higher</strong> installed.</li><li><strong>Maven or Gradle</strong> for dependency management.</li><li><strong>HAPI FHIR library</strong> (artifactId: hapi-fhir-structures-r5).</li><li><strong>Jackson Databind library</strong> for JSON processing.</li><li>A <strong>JSON configuration file</strong> defining field mappings.</li></ul><h3>Getting Started</h3><h4>1. Clone the Repository</h4><p>To get started, clone the repository from GitHub:</p><pre>git clone https://github.com/Youngsoft-India/common-fhir-java-library.git</pre><h4>2. Build the Project</h4><p>After cloning, navigate to the project directory and build the JAR file using Maven:</p><pre>mvn clean install</pre><h4>3. Include the JAR in Your Project</h4><p>Once the build is complete, add the generated JAR file to your Java project dependencies.</p><h3>Configuring the Library</h3><h4>4. Create a JSON Configuration File</h4><p>The conversion process is controlled through a JSON configuration file, which defines how Java object fields are mapped to FHIR fields.</p><p>Example config.json:</p><pre>{<br>    &quot;clientClass&quot;: &quot;org.ysifhir.MyPatient4&quot;,<br>    &quot;fhirMapperClass&quot;: &quot;Patient&quot;,<br>    &quot;fieldMapping&quot;: [<br>        {<br>            &quot;from&quot;: &quot;fullName&quot;,<br>            &quot;to&quot;: {<br>                &quot;dataType&quot;: &quot;HumanName&quot;,<br>                &quot;fieldName&quot;: &quot;name&quot;,<br>                &quot;fields&quot;: [<br>                    {<br>                        &quot;from&quot;: &quot;fullName&quot;,<br>                        &quot;to&quot;: &quot;text&quot;<br>                    },<br>                    {<br>                        &quot;from&quot;: &quot;lastName&quot;,<br>                        &quot;to&quot;: &quot;family&quot;<br>                    }<br>                ]<br>            }<br>        },<br>        {<br>            &quot;from&quot;: &quot;dateOfBirth&quot;,<br>            &quot;to&quot;: {<br>                &quot;dataType&quot;: &quot;DateType&quot;,<br>                &quot;fieldName&quot;: &quot;birthDate&quot;<br>            }<br>        },<br>        {<br>            &quot;from&quot;: &quot;gender&quot;,<br>            &quot;to&quot;: {<br>                &quot;dataType&quot;: &quot;AdministrativeGender&quot;,<br>                &quot;fieldName&quot;: &quot;gender&quot;<br>            }<br>        }<br>    ]<br>}</pre><h4>5. Define Your Java Model</h4><p>Below is an example of a Java object that we will convert into a FHIR resource:</p><pre>public class MyPatient4 {<br>    private String fullName;<br>    private String lastName;<br>    private String dateOfBirth;<br>    private String gender;<br>    private String address;<br>    private String phone;<br>    private String email;<br><br>    // Getters and Setters<br>}</pre><h4>6. Use the Library to Convert Java Objects to FHIR</h4><p>Once the JAR is included, you can use the FHIRConverter class to convert Java objects to FHIR JSON.</p><p>Example usage:</p><pre>import org.ysifhir.FHIRConverter;<br>import org.ysifhir.MyPatient4;<br>import java.nio.file.Files;<br>import java.nio.file.Paths;<br><br>public class MainConverter {<br>    public static void main(String[] args) throws Exception {<br>        // Read the JSON configuration file<br>        String jsonConfig = new String(Files.readAllBytes(Paths.get(&quot;path_to_your_config_file.json&quot;)));<br><br>        // Create and populate an instance of MyPatient4<br>        MyPatient4 sourceObj = new MyPatient4();<br>        sourceObj.setFullName(&quot;John Doe&quot;);<br>        sourceObj.setLastName(&quot;Doe&quot;);<br>        sourceObj.setDateOfBirth(&quot;2001-11-26&quot;);<br>        sourceObj.setGender(&quot;Male&quot;);<br>        sourceObj.setAddress(&quot;123 Main St, Springfield, IL&quot;);<br>        sourceObj.setPhone(&quot;123-456-7890&quot;);<br>        sourceObj.setEmail(&quot;john.doe@example.com&quot;);<br><br>        // Convert Java object to FHIR<br>        FHIRConverter converter = new FHIRConverter(jsonConfig);<br>        String fhirObjJson = converter.toFHIR(sourceObj);<br><br>        // Output the resulting FHIR JSON<br>        System.out.println(fhirObjJson);<br>    }<br>}</pre><h3>Advantages of Using This Library</h3><ul><li><strong>Saves Development Time:</strong> No need to manually create FHIR objects; just configure mappings.</li><li><strong>Reduces Complexity:</strong> Automatically maps Java object fields to FHIR fields.</li><li><strong>Flexible and Extensible:</strong> Can be extended with custom mappings and conversions.</li><li><strong>Open Source &amp; Community-Driven:</strong> Anyone can contribute and improve the library.</li></ul><h3>Contribute to the Project</h3><p>Since this is an open-source project, we welcome contributions! If you’d like to improve the library or report issues, feel free to fork the repository and submit pull requests.</p><p>GitHub Repository: <a href="https://github.com/Youngsoft-India/common-fhir-java-library">Common FHIR Java Library</a></p><h3>Conclusion</h3><p>The <strong>Common FHIR Java Library</strong> provides a robust and flexible way to dynamically convert Java objects into FHIR resources. With an easy-to-configure JSON mapping system, developers can integrate FHIR support into their projects without extensive modifications. Whether you’re working on healthcare applications or FHIR-based integrations, this library simplifies the process and saves valuable development time.</p><p>Give it a try and start building FHIR-compliant applications with ease!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69ca85db0e98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fast and Slow Pointers (Tortoise and Hare Algorithm)]]></title>
            <link>https://medium.com/@ajnabha6688/fast-and-slow-pointers-tortoise-and-hare-algorithm-75c5edcbf351?source=rss-a54e18a467d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/75c5edcbf351</guid>
            <dc:creator><![CDATA[Ajay]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 07:35:05 GMT</pubDate>
            <atom:updated>2025-01-24T09:19:24.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdIyAd5y5FWq-zYBmQggaA.jpeg" /></figure><p>The <strong>fast and slow pointer technique</strong> is a popular approach used in solving problems related to linked lists or arrays. It involves using two pointers that traverse the data structure at different speeds. This technique helps solve problems efficiently, often with reduced time and space complexity.</p><h3>Definitions of Key Terms</h3><ol><li><strong>Pointer:</strong> A variable that refers to a location in memory (e.g., a node in a linked list or an index in an array).</li><li><strong>Slow Pointer:</strong> Moves one step at a time through the data structure.</li><li><strong>Fast Pointer:</strong> Moves two steps (or at a faster pace) at a time.</li></ol><h3>Why Is This Important in DSA?</h3><p>The fast and slow pointer technique:</p><ul><li>Helps detect <strong>cycles</strong> in linked lists.</li><li>Identifies the <strong>middle</strong> of a linked list efficiently.</li><li>Determines specific patterns in linked lists or arrays with minimal overhead.</li><li>Simplifies problems that involve multiple traversal speeds.</li></ul><h3>Real-Life Analogy</h3><p>Imagine you’re jogging around a circular park track:</p><ul><li>You jog at a steady pace (slow pointer), while your friend bikes faster (fast pointer).</li><li>If there’s a cycle (loop in the track), your friend will eventually lap you (overtake you).</li><li>If it’s a straight track, your friend will finish far ahead without meeting you again.</li></ul><h3>Common Problems Solved Using Fast and Slow Pointers</h3><ol><li><strong>Cycle Detection in Linked List</strong></li></ol><ul><li>Check if a linked list contains a cycle.</li></ul><p><strong>2. Finding the Middle of a Linked List</strong></p><ul><li>Locate the middle node in a single pass.</li></ul><p><strong>3. Cycle Length Calculation</strong></p><ul><li>Measure the length of a loop in a circular linked list.</li></ul><p><strong>4. Palindrome Linked List</strong></p><ul><li>Check if a linked list represents a palindrome.</li></ul><h3>Example Problem: Detecting a Cycle in a Linked List</h3><h4>Problem Description</h4><p>Given the head of a linked list, determine if the list contains a cycle. A cycle occurs if a node in the list is revisited.</p><h3>Approach Using Fast and Slow Pointers</h3><ol><li>Use two pointers: slow and fast.</li><li>Move slow one step at a time.</li><li>Move fast two steps at a time.</li><li>If fast catches up to slow, there is a cycle.</li><li>If fast reaches the end (null), there is no cycle.</li></ol><pre>class ListNode {<br>    int value;<br>    ListNode next;<br><br>    ListNode(int value) {<br>        this.value = value;<br>        this.next = null;<br>    }<br>}<br><br>public class LinkedListCycleDetection {<br>    public static boolean hasCycle(ListNode head) {<br>        // Initialize the slow and fast pointers<br>        ListNode slow = head;<br>        ListNode fast = head;<br><br>        // Traverse the linked list<br>        while (fast != null &amp;&amp; fast.next != null) {<br>            slow = slow.next;         // Move slow by one step<br>            fast = fast.next.next;   // Move fast by two steps<br><br>            // Check if fast catches up to slow<br>            if (slow == fast) {<br>                return true; // Cycle detected<br>            }<br>        }<br>        return false; // No cycle detected<br>    }<br><br>    public static void main(String[] args) {<br>        // Create a linked list with a cycle<br>        ListNode head = new ListNode(1);<br>        head.next = new ListNode(2);<br>        head.next.next = new ListNode(3);<br>        head.next.next.next = new ListNode(4);<br>        head.next.next.next.next = head.next; // Create a cycle<br><br>        // Check for cycle<br>        System.out.println(&quot;Cycle detected: &quot; + hasCycle(head)); // Output: true<br>    }<br>}</pre><h3>Step-by-Step Explanation of the Code</h3><p>Define a ListNode class to represent each node in the linked list.</p><p>In the hasCycle method:</p><ul><li>Initialize slow and fast pointers to the head of the list.</li><li>Use a while loop to traverse the list as long as fast and fast.next are not null.</li><li>Move the slow pointer by one step (slow = slow.next) and the fast pointer by two steps (fast = fast.next.next).</li><li>Check if slow == fast. If true, a cycle exists.</li><li>If the loop exits without the pointers meeting, there is no cycle.</li></ul><p>In the main method:</p><ul><li>Create a sample linked list with a cycle for testing.</li><li>Call the hasCycle method to detect the cycle.</li></ul><h3>Best Practices</h3><ul><li><strong>Edge Cases:</strong> Always consider an empty list or a single-node list without a cycle.</li><li><strong>Avoid Infinite Loops:</strong> Ensure fast and fast.next are checked to avoid NullPointerException.</li><li><strong>Clean Code:</strong> Clearly separate logic for setting up the linked list and detecting the cycle.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75c5edcbf351" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>