Pesquisar

Artigo
· Out. 13 5min de leitura

REST api example for decode a Base64 data

Hi all,

 

It's me again 😁. In the pervious article Writing a REST api service for exporting the generated FHIR bundle in JSON, we actually generated a resource DocumentReference, with the content data encoded in Base64

 

Question!! Is it possible to write a REST service for decoding it? Because I am very curious what is the message data talking about🤔🤔🤔

OK, Let's start!

1. Create a new utility class datagen.utli.decodefhirjson.cls for decoding the data inside the DocumentReference
 

Class datagen.utli.decodefhirjson Extends %RegisteredObject
{
}

2. Write a Python function decodebase64docref to 
a. loop through the FHIR bundle
b. find out the resource DocumentReference
  - get the 1st element in the content
   - get the attachment from the content
     - get the data from the attachment
c. decode the data by Base64
 (this part I asked Chat-GPT to help me😂🤫) 

Class datagen.utli.decodefhirjson Extends %RegisteredObject
{

ClassMethod decodebase64docref(fhirbundle = "") As %String [ Language = python ]
{
    # w ##class(datagen.utli.decodefhirjson).decodebase64docref()
    import base64
    import json

    def decode_discharge_summary(bundle_json):
        """
        Extracts and decodes the Base64-encoded discharge summary note
        from a FHIR Bundle containing a DocumentReference.
        """
        for entry in bundle_json.get("entry", []):
            resource = entry.get("resource", {})
            if resource.get("resourceType") == "DocumentReference":
                # Traverse to the attachment
                content_list = resource.get("content", [])
                if not content_list:
                    continue
                attachment = content_list[0].get("attachment", {})
                base64_data = attachment.get("data")
                if base64_data:
                    decoded_text = base64.b64decode(base64_data).decode("utf-8")
                    return decoded_text
        return None


    # Example usage
    # Load your FHIR Bundle JSON from a file or object
    #with open("fhir_bundle.json", "r") as f:
    #    fhir_bundle = json.loads(f)
    if fhirbundle=="":
        rtstr=f"⚠️ No input found - JSON string is required."
        jsstr={"operation_outcome" : rtstr}
        return json.dumps(jsstr, indent=2)

    fhir_bundle = json.loads(fhirbundle)
    decoded_note = decode_discharge_summary(fhir_bundle)

    if decoded_note:
        #print("📝 Decoded Discharge Summary:\n")
        #print(decoded_note)
        rtstr=f"📝 Decoded Discharge Summary:\n {decoded_note}"
    else:
        #print("⚠️ No DocumentReference with Base64 note found.")
        rtstr=f"⚠️ No DocumentReference with Base64 note found."
    jsstr={"data" : rtstr}
    return json.dumps(jsstr, indent=2)
}

}

 

For testing this function, I try do some trick, which is making use of the function genfhirbundle to generate FHIR bundle in JSON string,  in the pervious article Writing a REST api service for exporting the generated FHIR bundle in JSON 

Let's generated a FHIR bundle and store into a variable jsonstr

set jsonstr=##class(datagen.utli.genfhirjson).genfhirbundle(1)

The test the decode function decodebase64docref  with the jsonstr

w ##class(datagen.utli.decodefhirjson).decodebase64docref(jsonstr)

OK 😉 Looks good. Now I can read the decode message.


 

Now, go back the pervious and pervious article Writing a REST api service for exporting the generated patient data in .csv

We would like to add a new function and update the route for the datagen.restservice class.

1. Add a new function DecodeDocRef, which is expecting to handle the FHIR bundle  attached in the body in JSON format.

i.e. In this case, we are expecting a POST.

the body content is packaged as %CSP.BinaryStream by default and stored in the variable %request.Content, so we can use the .Read() function  from the class %CSP.BinaryStream to read the BinaryStream

ClassMethod DecodeDocRef() As %Status
{
    // get body - json string
    #dim bistream As %CSP.BinaryStream =""
    set bistream=%request.Content
    set jsstr=bistream.Read()
    
    //decode the Document Reference data
    w ##class(datagen.utli.decodefhirjson).decodebase64docref(jsstr)
    return $$$OK
}

 

2. Then we add a route for the REST service and compile😀

<Route Url="/decode/docref" Method="POST" Call="DecodeDocRef" />

the updated  datagen.restservice class will look like the following.

 


Great!! That's all we need to do!😁

Let's test in postman!!

POST the following path

localhost/irishealth/csp/mpapp/decode/docref

with the following body ( I simplified FHIR bundle, you may test the full one😀)

{
    "resourceType": "Bundle",
    "type": "transaction",
    "id": "98bfce83-7eb1-4afe-bf2b-42916512244e",
    "meta": {
        "lastUpdated": "2025-10-13T05:49:07Z"
    },
    "entry": [
        {
            "fullUrl": "urn:uuid:5be1037d-a481-45ca-aea9-2034e27ebdcd",
            "resource": {
                "resourceType": "DocumentReference",
                "id": "5be1037d-a481-45ca-aea9-2034e27ebdcd",
                "status": "current",
                "type": {
                    "coding": [
                        {
                            "system": "http://loinc.org",
                            "code": "18842-5",
                            "display": "Discharge summary"
                        }
                    ]
                },
                "subject": {
                    "reference": "9e3a2636-4e87-4dee-b202-709d6f94ed18"
                },
                "author": [
                    {
                        "reference": "2aa54642-6743-4153-a171-7b8a8004ce5b"
                    }
                ],
                "context": {
                    "encounter": [
                        {
                            "reference": "98cd848b-251f-4d0b-bf36-e35c9fe68956"
                        }
                    ]
                },
                "content": [
                    {
                        "attachment": {
                            "contentType": "text/plain",
                            "language": "en",
                            "data": "RGlzY2hhcmdlIHN1bW1hcnkgZm9yIHBhdGllbnQgOWUzYTI2MzYtNGU4Ny00ZGVlLWIyMDItNzA5ZDZmOTRlZDE4LiBEaWFnbm9zaXM6IFN0YWJsZS4gRm9sbG93LXVwIGluIDIgd2Vla3Mu",
                            "title": "Discharge Summary Note"
                        }
                    }
                ]
            },
            "request": {
                "method": "POST",
                "url": "DocumentReference"
            }
        }
    ]
}

Works well!!!😆😉

Thank you very much for reading. 😘

2 Comments
Discussão (2)1
Entre ou crie uma conta para continuar
Pergunta
· Out. 13

GOOG vs GOOGL: Understanding the Real Difference for Investors in 2025

 

Goog Vs Googl

 

When it comes to investing in tech giants, Google’s parent company, Alphabet Inc., continues to be one of the most discussed names in the stock market. However, new and even experienced investors often face confusion when they see two ticker symbols — GOOG and GOOGL — representing the same company. If both are Alphabet Inc. shares, what makes them different? Which one should you invest in? This detailed GOOG vs GOOGL review for 2025 breaks down the differences, ownership structures, and performance insights to help investors make informed decisions.

Introduction to Alphabet Inc. and Its Dual-Class Shares

Alphabet Inc. is the parent company of Google, the global leader in search engines, online advertising, and digital innovation. When Alphabet restructured in 2015, it introduced a dual-class share system to maintain control among its founders while still allowing public investment. This system gave birth to two major types of publicly traded shares — GOOG and GOOGL. The goal was simple: allow outside investors to buy into the company while ensuring that co-founders Larry Page and Sergey Brin retain decision-making authority.

GOOG vs GOOGL: The Core Difference

The primary difference between GOOG and GOOGL stocks lies in their voting rights. Both represent ownership in Alphabet Inc., but not all shares are created equal.

  • GOOGL (Class A) shares carry voting rights, allowing shareholders to have a say in company decisions, such as electing board members and approving major corporate policies.
  • GOOG (Class C) shares do not include voting rights, meaning investors can benefit financially but have no influence over company governance.

To summarize in simple terms, GOOGL gives you a voice, while GOOG gives you returns without a vote.

This dual-class structure was introduced in 2014 after a stock split designed to ensure that founders maintained control over company direction even as Alphabet grew into a trillion-dollar entity.

Why Alphabet Created Two Classes of Shares

The introduction of two types of shares wasn’t random. Alphabet’s leadership wanted to prevent the dilution of control that typically occurs when companies expand ownership.

By creating Class B shares (held only by insiders with ten times the voting power of Class A shares), Alphabet secured the founders’ dominance over strategic decisions.

Public investors could choose between GOOG and GOOGL, depending on whether they valued voting rights or slightly better liquidity and price efficiency. This structure mirrors a growing trend among major tech firms, where founders want to maintain long-term vision control while giving investors access to growth opportunities.

Price Differences Between GOOG and GOOGL

Though GOOG and GOOGL stocks represent the same company, their prices often differ slightly. The difference—usually a few dollars per share—arises mainly from investor demand for voting rights. Historically, GOOGL tends to trade at a small premium because of its voting privilege, though market conditions and investor sentiment can occasionally flip that.

Over time, price variations have narrowed as investors realized that the lack of voting rights in GOOG doesn’t impact their financial gains significantly. For many retail investors, performance, dividends, and company growth matter far more than voting power.

Which One Is Better: GOOG or GOOGL?

When comparing GOOG vs GOOGL, the choice depends on your investment priorities.

  • If you value having a say in company decisions and plan to hold long-term, GOOGL might suit you better.
  • If you’re focused on returns, liquidity, and ease of trading, GOOG is equally strong, often trading in higher volume.

From a purely financial perspective, the returns on GOOG and GOOGL have historically been nearly identical. The differences lie in governance rights, not performance. For institutional investors or those holding large volumes, GOOGL may seem slightly more attractive. But for retail investors, GOOG’s flexibility and minimal price difference make it a great choice.

Ultimately, neither is “better” in terms of returns; it depends on what kind of investor you are — a decision-maker or a profit-seeker.

Alphabet’s Stock Performance and Investor Outlook in 2025

As of 2025, Alphabet remains one of the most dominant players in the technology and advertising sectors. The company’s growth is fueled by advancements in artificial intelligence, cloud computing, YouTube, and autonomous vehicle projects.

Both GOOG and GOOGL stocks have continued to reward investors with strong financial results, consistent revenue growth, and expanding profit margins. Alphabet’s focus on innovation, strategic acquisitions, and AI leadership has made both tickers popular among institutional and retail investors alike.

Even during periods of market volatility, Alphabet’s diversified revenue sources — particularly through Google Search and YouTube Ads — have provided stability. With strong fundamentals, both GOOG and GOOGL remain long-term growth investments rather than short-term trades.

Investor Sentiment: How the Market Views GOOG vs GOOGL

Investor sentiment around GOOG vs GOOGL stock has remained positive. Analysts continue to rate Alphabet as a buy or strong buy, citing its dominance in digital advertising and its rapid integration of AI into core products.

However, some investors prefer GOOGL for its symbolic participation in corporate governance, even if voting power is limited in practice. Others view GOOG as slightly more convenient for trading or for inclusion in certain index funds that prefer non-voting shares.

Both versions benefit equally from Alphabet’s continued stock buybacks, which help boost shareholder value and earnings per share.

Tax Implications and Dividends

Currently, Alphabet does not pay dividends, meaning investors rely solely on capital appreciation for returns. Tax treatment for GOOG and GOOGL is identical because they represent the same company ownership.

When Alphabet eventually considers dividends in the future, both classes are expected to receive equal payouts. Thus, tax planning doesn’t need to factor into whether you choose GOOG or GOOGL.

The Role of Index Funds and ETFs

Another interesting aspect of GOOG vs GOOGL is their presence in index funds and ETFs. Some funds may prefer GOOG because of its higher liquidity and slightly lower trading costs. Others, like governance-oriented funds, may hold GOOGL to represent shareholder voting rights.

Regardless of which fund you invest in, both share classes contribute equally to Alphabet’s market capitalization, ensuring that the company remains among the most influential stocks in major indices like the S&P 500 and NASDAQ-100.

Alphabet’s Future and Long-Term Outlook

Looking ahead, Alphabet’s growth potential remains strong. The company continues to dominate search and advertising, while expanding into AI, quantum computing, cloud technology, and hardware innovation. Its recent focus on integrating generative AI into Google Search and Workspace products positions it as a leader in the next technological revolution. For investors, this means both GOOG and GOOGL are strategic long-term holdings that could deliver sustained growth in the coming years. As Alphabet expands further into diverse business areas, its dual-share structure ensures leadership stability while offering the public a chance to share in its success.

Final Thoughts: GOOG vs GOOGL – Which Should You Choose in 2025?

Choosing between GOOG vs GOOGL ultimately depends on your investment goals:

  • Choose GOOGL if you prefer to have voting rights and want to feel part of the company decision-making, even if your influence is small.
  • Choose GOOG if you focus purely on financial returns, liquidity, and ease of trading.

From a long-term investor’s perspective, both stocks are virtually identical in performance. The distinction is more about governance preference than profitability. Alphabet remains one of the world’s most innovative and financially sound companies. Whether you pick GOOG or GOOGL, you’re investing in a company shaping the future of digital technology.

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· Out. 13 13min de leitura

Writing a REST api service for exporting the generated FHIR bundle in JSON

 

Hi all,

 

Let's do some more work about the testing data generation and export the result by REST API.😁

Here, I would like to reuse the datagen.restservice class which built in the pervious article Writing a REST api service for exporting the generated patient data in .csv

This time, we are planning to generate a FHIR bundle include multiple resources for testing the FHIR repository.

Here is some reference for you, if you want to know mare about FHIR The Concept of FHIR: A Healthcare Data Standard Designed for the Future

 

OK... Let's start😆

1. Create a new utility class datagen.utli.genfhirjson.cls for hosting the FHIR data generation functions

Class datagen.utli.genfhirjson Extends %RegisteredObject
{
}

 

2. Write a Python function genfhirbundle to generate FHIR bundle in JSON string (this part I asked Chat-GPT to help me😂🤫)

- here, I added an argument isirisfhir (default value is 0) to indicate if this FHIR bundle is sending to IRIS FHIR repository or not.

The reason of doing this is the different syntax of resource reference while using uuid 

For example some of the FHIR repository by referencing a patient resource using uuid looks like the following

 "subject": {
          "reference": "Patient/3ce18a5b-b904-4c77-8a33-b09c3f8c79cc"
        }

 While IRIS FHIR repository by referencing a patient resource using uuid looks like the following

 "subject": {
          "reference": "3ce18a5b-b904-4c77-8a33-b09c3f8c79cc"
        }

As a result, an argument is added as a selector

Class datagen.utli.genfhirjson Extends %RegisteredObject
{

ClassMethod genfhirbundle(isirisfhir = 0) As %String [ Language = python ]
{
    # w ##class(datagen.utli.genfhirjson).genfhirbundle(0)
    # w ##class(datagen.utli.genfhirjson).genfhirbundle(1)
    from faker import Faker
    import random
    import json
    import uuid
    from datetime import datetime
    import base64

    fake = Faker()


    # ----------------------
    # Patient
    # ----------------------
    def generate_fhir_patient():
        patient_id = str(uuid.uuid4())
        return {
            "resourceType": "Patient",
            "id": patient_id,
            "identifier": [{
                "use": "usual",
                "system": "http://hospital.smarthealth.org/patient-ids",
                "value": str(random.randint(100000, 999999))
            }],
            "name": [{
                "use": "official",
                "family": fake.last_name(),
                "given": [fake.first_name()]
            }],
            "gender": random.choice(["male", "female"]),
            "birthDate": fake.date_of_birth(minimum_age=0, maximum_age=100).strftime("%Y-%m-%d"),
            "address": [{
                "use": "home",
                "line": [fake.street_address()],
                "city": fake.city(),
                "state": fake.state(),
                "postalCode": fake.postcode(),
                "country": fake.country()
            }],
            "telecom": [{
                "system": "phone",
                "value": fake.phone_number(),
                "use": "mobile"
            }],
            "meta": {"lastUpdated": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}
        }


    # ----------------------
    # Practitioner
    # ----------------------
    def generate_fhir_practitioner():
        practitioner_id = str(uuid.uuid4())
        return {
            "resourceType": "Practitioner",
            "id": practitioner_id,
            "identifier": [{
                "system": "http://hospital.smarthealth.org/staff-ids",
                "value": str(random.randint(1000, 9999))
            }],
            "name": [{
                "family": fake.last_name(),
                "given": [fake.first_name()],
                "prefix": ["Dr."]
            }],
            "telecom": [{
                "system": "phone",
                "value": fake.phone_number(),
                "use": "work"
            }],
            "meta": {"lastUpdated": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}
        }


    # ----------------------
    # Encounter
    # ----------------------
    def generate_fhir_encounter(patient_id, practitioner_id):
        encounter_id = str(uuid.uuid4())
        if isirisfhir==0:
            patient_ref=f"Patient/{patient_id}"
            practitioner_ref=f"Practitioner/{practitioner_id}"
        else:
            patient_ref=patient_id
            practitioner_ref=practitioner_id
        return {
            "resourceType": "Encounter",
            "id": encounter_id,
            "status": "finished",
            "class": {
                "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                "code": "AMB",
                "display": "ambulatory"
            },
            "subject": {"reference": patient_ref},
            "participant": [{
                "individual": {"reference": practitioner_ref}
            }],
            "period": {
                "start": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
                "end": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
            }
        }


    # ----------------------
    # Condition
    # ----------------------
    def generate_fhir_condition(patient_id, encounter_id, practitioner_id):
        condition_id = str(uuid.uuid4())
        code_choice = random.choice([
            ("44054006", "Diabetes mellitus"),
            ("195967001", "Asthma"),
            ("38341003", "Hypertension"),
            ("254637007", "Viral upper respiratory tract infection")
        ])
        if isirisfhir==0:
            patient_ref=f"Patient/{patient_id}"
            practitioner_ref=f"Practitioner/{practitioner_id}"
            encounter_ref=f"Encounter/{encounter_id}"
        else:
            patient_ref=patient_id
            practitioner_ref=practitioner_id
            encounter_ref=encounter_id
        return {
            "resourceType": "Condition",
            "id": condition_id,
            "clinicalStatus": {
                "coding": [{
                    "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
                    "code": "active"
                }]
            },
            "code": {
                "coding": [{
                    "system": "http://snomed.info/sct",
                    "code": code_choice[0],
                    "display": code_choice[1]
                }]
            },
            "subject": {"reference": patient_ref},
            "encounter": {"reference": encounter_ref},
            "asserter": {"reference": practitioner_ref},
            "onsetDateTime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
        }


    # ----------------------
    # Vitals Observation
    # ----------------------
    def generate_fhir_vitals(patient_id, encounter_id, practitioner_id):
        observation_id = str(uuid.uuid4())
        if isirisfhir==0:
            patient_ref=f"Patient/{patient_id}"
            practitioner_ref=f"Practitioner/{practitioner_id}"
            encounter_ref=f"Encounter/{encounter_id}"
        else:
            patient_ref=patient_id
            practitioner_ref=practitioner_id
            encounter_ref=encounter_id
        return {
            "resourceType": "Observation",
            "id": observation_id,
            "status": "final",
            "category": [{
                "coding": [{
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "vital-signs",
                    "display": "Vital Signs"
                }]
            }],
            "code": {
                "coding": [{
                    "system": "http://loinc.org",
                    "code": "85354-9",
                    "display": "Blood pressure panel"
                }]
            },
            "subject": {"reference": patient_ref},
            "encounter": {"reference": encounter_ref},
            "performer": [{"reference": practitioner_ref}],
            "effectiveDateTime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
            "component": [
                {
                    "code": {
                        "coding": [{
                            "system": "http://loinc.org",
                            "code": "8480-6",
                            "display": "Systolic blood pressure"
                        }]
                    },
                    "valueQuantity": {
                        "value": random.randint(100, 140),
                        "unit": "mmHg",
                        "system": "http://unitsofmeasure.org",
                        "code": "mm[Hg]"
                    }
                },
                {
                    "code": {
                        "coding": [{
                            "system": "http://loinc.org",
                            "code": "8462-4",
                            "display": "Diastolic blood pressure"
                        }]
                    },
                    "valueQuantity": {
                        "value": random.randint(60, 90),
                        "unit": "mmHg",
                        "system": "http://unitsofmeasure.org",
                        "code": "mm[Hg]"
                    }
                }
            ]
        }


    # ----------------------
    # Lab Observations
    # ----------------------
    def generate_fhir_lab(patient_id, encounter_id, practitioner_id):
        labs = [
            ("2339-0", "Glucose [Mass/volume] in Blood", "mg/dL", random.randint(70, 200)),
            ("2093-3", "Cholesterol [Mass/volume] in Serum", "mg/dL", random.randint(150, 250)),
            ("4548-4", "Hemoglobin A1c/Hemoglobin.total in Blood", "%", round(random.uniform(4.5, 10.0), 1))
        ]
        lab_obs = []
        if isirisfhir==0:
            patient_ref=f"Patient/{patient_id}"
            practitioner_ref=f"Practitioner/{practitioner_id}"
            encounter_ref=f"Encounter/{encounter_id}"
        else:
            patient_ref=patient_id
            practitioner_ref=practitioner_id
            encounter_ref=encounter_id
        for loinc, display, unit, value in labs:
            obs_id = str(uuid.uuid4())
            lab_obs.append({
                "resourceType": "Observation",
                "id": obs_id,
                "status": "final",
                "category": [{
                    "coding": [{
                        "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                        "code": "laboratory",
                        "display": "Laboratory"
                    }]
                }],
                "code": {
                    "coding": [{
                        "system": "http://loinc.org",
                        "code": loinc,
                        "display": display
                    }]
                },
                "subject": {"reference": patient_ref},
                "encounter": {"reference": encounter_ref},
                "performer": [{"reference": practitioner_ref}],
                "effectiveDateTime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
                "valueQuantity": {
                    "value": value,
                    "unit": unit,
                    "system": "http://unitsofmeasure.org",
                    "code": unit
                }
            })
        return lab_obs


    # ----------------------
    # Medication + MedicationRequest
    # ----------------------
    def generate_fhir_medication(patient_id, encounter_id, practitioner_id):
        meds = [
            ("860975", "Metformin 500mg tablet"),
            ("860976", "Lisinopril 10mg tablet"),
            ("860977", "Salbutamol inhaler"),
            ("860978", "Atorvastatin 20mg tablet")
        ]
        med_code, med_name = random.choice(meds)
        med_id = str(uuid.uuid4())
        med_request_id = str(uuid.uuid4())
        if isirisfhir==0:
            patient_ref=f"Patient/{patient_id}"
            practitioner_ref=f"Practitioner/{practitioner_id}"
            encounter_ref=f"Encounter/{encounter_id}"
        else:
            patient_ref=patient_id
            practitioner_ref=practitioner_id
            encounter_ref=encounter_id

        medication = {
            "resourceType": "Medication",
            "id": med_id,
            "code": {
                "coding": [{
                    "system": "http://www.nlm.nih.gov/research/umls/rxnorm",
                    "code": med_code,
                    "display": med_name
                }]
            }
        }

        medication_request = {
            "resourceType": "MedicationRequest",
            "id": med_request_id,
            "status": "active",
            "intent": "order",
            "medicationReference": {"reference": f"Medication/{med_id}"},
            "subject": {"reference": patient_ref},
            "encounter": {"reference": encounter_ref},
            "requester": {"reference": practitioner_ref},
            "authoredOn": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
            "dosageInstruction": [{
                "text": f"Take {random.randint(1,2)} tablet(s) daily"
            }]
        }

        return [medication, medication_request]


    # ----------------------
    # DocumentReference (Discharge Summary)
    # ----------------------
    def generate_fhir_documentreference(patient_id, encounter_id, practitioner_id):
        doc_id = str(uuid.uuid4())
        note_text = f"Discharge summary for patient {patient_id}. Diagnosis: Stable. Follow-up in 2 weeks."
        encoded_note = base64.b64encode(note_text.encode("utf-8")).decode("utf-8")
        if isirisfhir==0:
            patient_ref=f"Patient/{patient_id}"
            practitioner_ref=f"Practitioner/{practitioner_id}"
            encounter_ref=f"Encounter/{encounter_id}"
        else:
            patient_ref=patient_id
            practitioner_ref=practitioner_id
            encounter_ref=encounter_id

        return {
            "resourceType": "DocumentReference",
            "id": doc_id,
            "status": "current",
            "type": {
                "coding": [{
                    "system": "http://loinc.org",
                    "code": "18842-5",
                    "display": "Discharge summary"
                }]
            },
            "subject": {"reference": patient_ref},
            "author": [{"reference": practitioner_ref}],
            "context": {"encounter": [{"reference": encounter_ref}]},
            "content": [{
                "attachment": {
                    "contentType": "text/plain",
                    "language": "en",
                    "data": encoded_note,
                    "title": "Discharge Summary Note"
                }
            }]
        }


    # ----------------------
    # Bundle Generator (transaction)
    # ----------------------
    def generate_patient_bundle(n=1):
        bundle = {
            "resourceType": "Bundle",
            "type": "transaction",
            "id": str(uuid.uuid4()),
            "meta": {"lastUpdated": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")},
            "entry": []
        }

        for _ in range(n):
            patient = generate_fhir_patient()
            practitioner = generate_fhir_practitioner()
            encounter = generate_fhir_encounter(patient["id"], practitioner["id"])
            condition = generate_fhir_condition(patient["id"], encounter["id"], practitioner["id"])
            vitals = generate_fhir_vitals(patient["id"], encounter["id"], practitioner["id"])
            labs = generate_fhir_lab(patient["id"], encounter["id"], practitioner["id"])
            meds = generate_fhir_medication(patient["id"], encounter["id"], practitioner["id"])
            docref = generate_fhir_documentreference(patient["id"], encounter["id"], practitioner["id"])

            all_resources = [patient, practitioner, encounter, condition, vitals] + labs + meds + [docref]

            for resource in all_resources:
                bundle["entry"].append({
                    "fullUrl": f"urn:uuid:{resource['id']}",
                    "resource": resource,
                    "request": {
                        "method": "POST",
                        "url": resource["resourceType"]
                    }
                })

        return bundle


    # ----------------------
    # Example Run
    # ----------------------
    fhir_bundle = generate_patient_bundle(1)

    return json.dumps(fhir_bundle, indent=2)
}

}

Let's test the function by the following script, for generating FHIR bundle for non IRIS FHIR repository

w ##class(datagen.utli.genfhirjson).genfhirbundle(0)

and check the reference syntax

 

Now test the function by the following script, for generating FHIR bundle for IRIS FHIR repository😁

w ##class(datagen.utli.genfhirjson).genfhirbundle(1)

and check the reference syntax

 


Great! Now go back the pervious article Writing a REST api service for exporting the generated patient data in .csv

We would like to add a new function and update the route for the datagen.restservice class.

 

1. Add a new function GenFHIRBundle, with an parameter isirisfhir for indicating which kind of reference syntax we prefer.

If no parameters are input, it will out put the reference syntax for non IRIS FHIR repository

ClassMethod GenFHIRBundle() As %Status
{
    // get the parameter isirisfhir
    set isirisfhir=$GET(%request.Data("isirisfhir",1),"")
    // default value for non - IRIS repository
    if isirisfhir="" set isirisfhir=0
    // gen the FHIR bundle
    w ##class(datagen.utli.genfhirjson).genfhirbundle(isirisfhir)
    
    return $$$OK
}

2. Then we add a route for the REST service and compile😀

<Route Url="/gen/fhirbundle" Method="GET" Call="GenFHIRBundle"/>

the updated  datagen.restservice class will look like the following.

 


Great!! That's all we need to do!😁

Let's test in postman!!

Try to GET by the following URL for generating FHIR bundle for non IRIS FHIR repository

localhost/irishealth/csp/mpapp/gen/fhirbundle

 

 

Looks good!!

Now Try to GET by the following URL for generating FHIR bundle for IRIS FHIR repository
 

localhost/irishealth/csp/mpapp/gen/fhirbundle?isirisfhir=1

 

Works well!!!😆😉

Thank you very much for reading. 😘

1 novo comentário
Discussão (1)2
Entre ou crie uma conta para continuar
Resumo
· Out. 13
Artigo
· Out. 12 5min de leitura

Everything Need to Know Custom Corrugated Plastic Boxes

 

These boxes are getting popular in all sorts of industries because they're durable and can be shaped to fit whatever you're shipping or storing. In this post, we'll break it down simply
custom corrugated plastic boxes​– from what they are to why you might want them. 

What Makes Custom Corrugated Plastic Boxes So Special?

Custom corrugated plastic boxes are basically boxes made from a type of plastic that's ridged like cardboard but way stronger. Think of them as the upgraded version of regular cardboard boxes. The "corrugated" part means they have those wavy layers inside, which give them extra strength without adding much weight.

These boxes aren't off-the-shelf; they're tailored to your specs. You can choose the size, shape, color, and even add prints or logos. Businesses use them for shipping products, displaying items, or even as reusable storage. Unlike paper boxes that tear easily, custom corrugated plastic boxes hold up against water, chemicals, and rough handling.

The Basics of Corrugated Plastic Material

Corrugated plastic is made from polypropylene or polyethylene sheets. It's like two flat layers with a fluted (wavy) middle that traps air, making it light yet rigid. This material is recyclable, which is a big plus for eco-friendly folks.

When you go custom, manufacturers use machines to cut, fold, and seal the sheets into boxes. You can get them in thicknesses from 2mm to 10mm, depending on how heavy-duty you need them.

Why Choose Plastic Over Cardboard?

Cardboard is cheap, but it flops in wet conditions. Custom corrugated plastic boxes stay strong even if they get rained on. They're also pest-resistant – no worries about bugs chewing through them like with paper.

Benefits of Using Custom Corrugated Plastic Boxes

One big perk is durability. These boxes can take a beating during transport without crushing your stuff inside. For example, if you're in e-commerce, custom corrugated plastic boxes protect fragile items like electronics or glassware better than flimsy options.

They're lightweight too, which cuts down on shipping costs. Imagine saving money on postage because your packages weigh less! Plus, they're reusable – wash them off and use them again, unlike single-use cardboard.

Cost-Effectiveness in the Long Run

At first, custom corrugated plastic boxes might cost more than basic cardboard. But over time, they pay off because they last longer. Businesses report fewer returns due to damaged goods, which means happier customers and less hassle.

Customization Options Galore

You can add handles, dividers, or even windows for visibility. Want your brand colors? No problem. Some companies even make them with UV protection for outdoor use.

Eco-Friendly Aspects

Many custom corrugated plastic boxes are made from recycled materials. They're fully recyclable at the end of their life, reducing waste. If you're going green, this is a smart choice.

How Are Custom Corrugated Plastic Boxes Made?

The process starts with designing. You tell the maker your needs – size, strength, quantity. They use CAD software to sketch it out.

Then, sheets of corrugated plastic are cut using die-cutting machines. Edges get sealed with heat or glue to form the box shape. If you want prints, they use screen printing or digital methods right on the plastic.

Quality Checks Along the Way

Good manufacturers test for strength, like drop tests or compression. This ensures your custom corrugated plastic boxes won't fail when it matters.

Industries That Love These Boxes

From agriculture to retail, they're everywhere. Farmers use them for produce bins because they're waterproof. In manufacturing, they store parts without rusting. Even event planners use them for signage or portable displays.

Tips for Ordering Your First Batch

Measure twice! Get samples if possible. Ask about minimum orders – some places start at 100 units.

Common Uses for Custom Corrugated Plastic Boxes

In packaging, they're great for odd-shaped items. Custom corrugated plastic boxes can be molded to fit perfectly, reducing movement and breakage.

For storage, think garages or warehouses. They're stackable and don't sag under weight.

Creative Applications Beyond Basics

Some people turn them into pet carriers or kids' toy boxes. They're versatile!

Maintenance and Care

Just wipe with soap and water. Avoid extreme heat to prevent warping.

Recycling and Disposal

When done, check local recycling centers. Most accept polypropylene.

Potential Drawbacks and How to Avoid Them

Nothing's perfect. Custom corrugated plastic boxes can be pricier upfront. Solution: Buy in bulk for discounts.

They might not insulate well for temperature-sensitive items. Add liners if needed.

Comparing to Other Materials

Vs. wood: Lighter and cheaper. Vs. metal: Won't rust, easier to handle.

Future Trends in Custom Boxes

Look for more biodegradable options. Tech like 3D printing might make customization faster.

Sustainability Innovations

Companies are blending in plant-based plastics for greener custom corrugated plastic boxes.

FAQs About Custom Corrugated Plastic Boxes

What is the difference between corrugated plastic and regular plastic boxes?

Corrugated has that wavy layer for strength, while regular might be solid and heavier.

How long do custom corrugated plastic boxes last?

With proper use, 5-10 years or more. They're built tough!

Can I get custom corrugated plastic boxes in small quantities?

Yes, but check with suppliers – some have minimums, others do one-offs.

Are custom corrugated plastic boxes waterproof?

Absolutely! That's one of their best features.

How do I design my own custom corrugated plastic boxes?

Start with sketches, then work with a manufacturer who offers design help.

Is printing on custom corrugated plastic boxes expensive?

It depends on complexity, but basic logos are affordable.

Final Thoughts

Wrapping up, custom corrugated plastic boxes are a solid pick for anyone needing reliable, tailored packaging. They're tough, light, and customizable, making them ideal for business or personal use. Just remember to research suppliers and think about your specific needs.

Discussão (0)1
Entre ou crie uma conta para continuar