Skip to content

Commit

Permalink
added some more patient and srv records
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmainguy committed Apr 16, 2018
1 parent 83df613 commit 4d29bf5
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 97 deletions.
91 changes: 91 additions & 0 deletions addPatients.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package main

import (
"strings"
"fmt"
)


func addPatient(v *Import, line []string){
patFullName := strings.Split(line[9], ",")
fullPatBirthDate := ""
fullSrvFromDate := ""
fullSrvToDate := ""
fullInsBirthDate := ""
insFirstName := ""
insLastName := ""
formatedSrvCharges := ""
fullPatPhoneNo := ""
fullInsPhone := ""
if line[10] != "" {
fullPatBirthDate = formatBirthDate(line[10],line[11],line[12])
}
if line[106] != "" {
fullSrvFromDate = formatBirthDate(line[106],line[107],line[108])
}
if line[109] != "" {
fullSrvToDate = formatBirthDate(line[109],line[110],line[111])
}
if line[37] != "" {
fullInsBirthDate = formatBirthDate(line[37],line[38],line[39])
}
if line[15] != "" {
insFullName := strings.Split(rm_lead_space(line[15]), " ")
if len(insFullName) > 1 {
insFirstName = rm_lead_space(insFullName[1])
insLastName = insFullName[0]
}
}
if line[118] != "" {
formatedSrvCharges = fmt.Sprintf("%s.%s", rm_lead_space(line[118]), rm_lead_space(line[119]))
}
if line[27] != "" {
fullPatPhoneNo = formatPhoneNumber(rm_lead_space(line[27]), rm_lead_space(line[28]))
}
if line[30] != "" {
fullInsPhone = formatPhoneNumber(rm_lead_space(line[30]), rm_lead_space(line[31]))
}
data := Patient{
PatFirstName: rm_lead_space(patFullName[1]),
PatLastName: patFullName[0],
PatAccountNo: rm_lead_space(line[225]),
PatAddress: rm_lead_space(line[16]),
PatBirthDate: fullPatBirthDate,
PatCity: rm_lead_space(line[22]),
PatPhoneNo: fullPatPhoneNo,
PatSigOnFile: "1",
PatState: rm_lead_space(line[23]),
PatZip: rm_lead_space(line[26]),
PatClassification: "Affinity Health Services- Smithfield",
Patient_Insured: Patient_Insured{
InsAddress: rm_lead_space(line[21]),
InsBirthDate: fullInsBirthDate,
InsCity: rm_lead_space(line[24]),
InsFirstName: insFirstName,
InsLastName: insLastName,
InsIDNumber: rm_lead_space(line[8]),
InsPhone: fullInsPhone,
InsState: rm_lead_space(line[25]),
InsZip: rm_lead_space(line[29]),
PatInsRelationToInsured: "1",
},
Claim: Claim{
ClaBillDate: rm_lead_space(line[222]),
Claim_Insured: Claim_Insured{
ClaInsAcceptAssignment: "1",
ClaInsPriorAuthorizationNumber: rm_lead_space(line[102]),
},
Service_Line: Service_Line{
SrvCharges: formatedSrvCharges,
SrvFromDate: fullSrvFromDate,
SrvPlace: rm_lead_space(line[112]),
SrvEMG: rm_lead_space(line[113]),
SrvProcedureCode: rm_lead_space(line[114]),
SrvModifier1: rm_lead_space(line[115]),
SrvToDate: fullSrvToDate,
SrvUnits: rm_lead_space(line[120]),
},
},
}
v.Patients = append(v.Patients, data)
}
26 changes: 26 additions & 0 deletions funcs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"fmt"
"strings"
)

func rm_lead_space(old_value string) (new_value string) {
new_value = strings.TrimLeft(old_value, " ")
return
}

func formatBirthDate(month, day, year string) (birthday string) {
birthday = fmt.Sprintf("%s%s/%s", rm_lead_space(month), rm_lead_space(day), rm_lead_space(year))
return
}

func formatPhoneNumber(areacode, number string) (phonenumber string) {
lastFour := number[3:len(number)]
firstThree := number[0:3]
phonenumber = fmt.Sprintf("%s-%s-%s", areacode, firstThree, lastFour)
return
}

//func addPayer(v *Import, line []string){
//}
103 changes: 6 additions & 97 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,15 @@ import (
"encoding/xml"
"fmt"
"io"
"strings"
)

func rm_lead_space(old_value string) (new_value string) {
new_value = strings.TrimLeft(old_value, " ")
return
}

func formatBirthDate(month, day, year string) (birthday string) {
birthday = fmt.Sprintf("%s%s/%s", rm_lead_space(month), rm_lead_space(day), rm_lead_space(year))
return
}

func formatPhoneNumber(areacode, number string) (phonenumber string) {
lastFour := number[3:len(number)]
firstThree := number[0:3]
phonenumber = fmt.Sprintf("%s-%s-%s", areacode, firstThree, lastFour)
return
}

func main() {

filename := "/tmp/jon.csv"
// Csv to read from
filename := "/tmp/export.csv"
// XML to write to
writefilename := "/tmp/patients.xml"
// Root of our xml doc
v := &Import{}

// Open CSV file
Expand All @@ -46,86 +32,9 @@ func main() {

// Loop through lines & turn into object
for _, line := range lines {
patFullName := strings.Split(line[9], ",")
fullPatBirthDate := ""
fullSrvFromDate := ""
fullSrvToDate := ""
fullInsBirthDate := ""
insFirstName := ""
insLastName := ""
formatedSrvCharges := ""
fullPatPhoneNo := ""
fullInsPhone := ""
if line[10] != "" {
fullPatBirthDate = formatBirthDate(line[10],line[11],line[12])
}
if line[106] != "" {
fullSrvFromDate = formatBirthDate(line[106],line[107],line[108])
}
if line[109] != "" {
fullSrvToDate = formatBirthDate(line[109],line[110],line[111])
}
if line[37] != "" {
fullInsBirthDate = formatBirthDate(line[37],line[38],line[39])
}
if line[15] != "" {
insFullName := strings.Split(rm_lead_space(line[15]), " ")
if len(insFullName) > 1 {
insFirstName = rm_lead_space(insFullName[1])
insLastName = insFullName[0]
}
}
if line[118] != "" {
formatedSrvCharges = fmt.Sprintf("%s.%s", rm_lead_space(line[118]), rm_lead_space(line[119]))
}
if line[27] != "" {
fullPatPhoneNo = formatPhoneNumber(rm_lead_space(line[27]), rm_lead_space(line[28]))
}
if line[30] != "" {
fullInsPhone = formatPhoneNumber(rm_lead_space(line[30]), rm_lead_space(line[31]))
}
data := Patient{
PatFirstName: rm_lead_space(patFullName[1]),
PatLastName: patFullName[0],
PatAddress: rm_lead_space(line[16]),
PatBirthDate: fullPatBirthDate,
PatCity: rm_lead_space(line[22]),
PatPhoneNo: fullPatPhoneNo,
PatSigOnFile: "1",
PatState: rm_lead_space(line[23]),
PatZip: rm_lead_space(line[26]),
Patient_Insured: Patient_Insured{
InsAddress: rm_lead_space(line[21]),
InsBirthDate: fullInsBirthDate,
InsCity: rm_lead_space(line[24]),
InsFirstName: insFirstName,
InsLastName: insLastName,
InsIDNumber: rm_lead_space(line[8]),
InsPhone: fullInsPhone,
InsState: rm_lead_space(line[25]),
InsZip: rm_lead_space(line[29]),
PatInsRelationToInsured: "1",
},
Claim: Claim{
ClaBillDate: rm_lead_space(line[222]),
Claim_Insured: Claim_Insured{
ClaInsAcceptAssignment: "1",
ClaInsPriorAuthorizationNumber: rm_lead_space(line[102]),
},
Service_Line: Service_Line{
SrvCharges: formatedSrvCharges,
SrvFromDate: fullSrvFromDate,
SrvPlace: rm_lead_space(line[112]),
SrvProcedureCode: rm_lead_space(line[114]),
SrvToDate: fullSrvToDate,
SrvUnits: rm_lead_space(line[120]),
},
},
}
v.Patients = append(v.Patients, data)
addPatient(v, line)
}

writefilename := "/tmp/patients.xml"
file, _ := os.Create(writefilename)

xmlWriter := io.Writer(file)
Expand Down
4 changes: 4 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ type Service_Line struct {
SrvCharges string `xml:"SrvCharges,omitempty"`
SrvFromDate string `xml:"SrvFromDate,omitempty"`
SrvPlace string `xml:"SrvPlace,omitempty"`
SrvEMG string `xml:"SrvEMG,omitempty"`
SrvProcedureCode string `xml:"SrvProcedureCode,omitempty"`
SrvModifier1 string `xml:"SrvModifier1,omitempty"`
SrvToDate string `xml:"SrvToDate,omitempty"`
SrvUnits string `xml:"SrvUnits,omitempty"`
}
Expand Down Expand Up @@ -45,13 +47,15 @@ type Patient struct {
XMLName xml.Name `xml:"Patient"`
PatFirstName string `xml:"PatFirstName"`
PatLastName string `xml:"PatLastName"`
PatAccountNo string `xml:"PatAccountNo,omitempty"`
PatAddress string `xml:"PatAddress,omitempty"`
PatBirthDate string `xml:"PatBirthDate,omitempty"`
PatCity string `xml:"PatCity,omitempty"`
PatPhoneNo string `xml:"PatPhoneNo,omitempty"`
PatSigOnFile string `xml:"PatSigOnFile,omitempty"`
PatState string `xml:"PatState,omitempty"`
PatZip string `xml:"PatZip,omitempty"`
PatClassification string `xml:"PatClassification,omitempty"`
Patient_Insured Patient_Insured `xml:"Patient_Insured,omitempty"`
Claim Claim `xml:"Claim"`
}
Expand Down

0 comments on commit 4d29bf5

Please sign in to comment.